0

I have the following functions declared in the repo:

fun loadAllNotifications(): Single<List<Notification>> fun insertAll(notifications: List<Notification>): Completable 

What I'd like to do is to loadAllNotifications() and then for each Notification reset its isOpened flag to false by doing something like

val updatedNotification = currentNotification.copy(isOpened = false) 

Once I have a list of Notifications with the isOpened set to false, I'd like to pass this list into insertAll(list)

How would I do the above in a single RxChain? Any help will be greatly appreciated.

1 Answer 1

1
loadAllNotifications() .flatMapObservable { Observable.fromIterable(it) } .map { it.copy(isOpened = false) } .toList() .flatMapCompletable{ insertAll(it) } 
Sign up to request clarification or add additional context in comments.

1 Comment

Brilliant. Thanks very much!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.