I have the following situation:
- I am using the RxKotlin extensions for detecting clicks in the buttons of my activity
- I am using Room for inserting records in a database
This is the code related in my activity:
button.clicks()
.flatMap {
val list = mutableListOf<Answer>()
val date = Date()
list.add(Answer("some placeholder info"))
list.add(Answer("Another placeholder info"))
Observable.fromArray(list)
}
.map {
upsertStatusQuestionsViewModel.insertMultipleAnswers(it)
}.subscribe {
// it here is an object Maybe<Answer>
}
And this is the code of the ViewModel:
fun insertMultipleAnswers(answers: List<Answer>) = database.answerDao()
.createMultiple(answers.toList())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
I would like to show some information about the answer inserted in the database, for that reason, I need to get the Answer object in my subscription. However, I don't know which operator can I use for achieving that the it object in the subscription is of class Answer, instead of Maybe<Answer>
.
Thanks a lot for your help!