Skip to content

Instantly share code, notes, and snippets.

@SeongUgJung
Created October 5, 2019 12:16
Show Gist options
  • Save SeongUgJung/676f381577d090d474186e045fedcf52 to your computer and use it in GitHub Desktop.
Save SeongUgJung/676f381577d090d474186e045fedcf52 to your computer and use it in GitHub Desktop.
class InteractorController(private val mapProvider:MapProvider,
private varargs val interactors: Interactor) {
fun onInit(): Completable {
return mapProvider.initMap()
.switchMapCompletable { map ->
Observable.fromIterable(mapInteractors.asIterable())
.flatMapCompletable { mapInteractor ->
mapInteractor.onInit(map)
}
}
.subscribe(Functions.EMPTY_ACTION, Consumer { Timber.e(it) })
}
fun onVisible(): Completable {
return mapProvider.getMap()
.switchMapCompletable { map ->
Observable.fromIterable(mapInteractors.asIterable())
.flatMapCompletable { mapInteractor ->
mapInteractor.onVisible(map)
}
}
.subscribe(Functions.EMPTY_ACTION, Consumer { Timber.e(it) })
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment