Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- override fun onFirstViewAttach() {
- super.onFirstViewAttach()
- Flowable
- .combineLatest<List<AccreditationItem>, List<Event>, Pair<List<AccreditationItem>, List<Event>>>(
- repository.getAccreditations(),
- eventRepo.observeEvents(),
- BiFunction { accreditations, events ->
- Pair(accreditations, events)
- }
- )
- .map { pair ->
- val accreditations = pair.first
- val events = pair.second
- events.mapNotNull { event ->
- val eventAccreditation = accreditations.firstOrNull { it.eventId == event.eventId }
- event.name?.let { eventAccreditation?.barcode?.let { it1 -> EventAccreditation(it, it1) } }
- }
- }
- .observeOn(schedulers.ui())
- .subscribeOn(schedulers.io())
- .subscribe({
- if (!it.isNullOrEmpty())
- viewState.loadData(it)
- else
- throw Throwable()
- }, {
- viewState.onError()
- })
- .untilDestroy()
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement