Slide 48
Slide 48 text
Action / Dispatcher
class ArchiveAction(private val dispatcher: ArchiveDispatcher, private val
programRepository: ProgramRepository) {
fun refresh() {
programRepository.getProgramsArchive(count = 20, offset = 0)
.subscribe({
dispatcher.archiveDao.replaceAll(it)
}, {
dispatcher.onError(this, it, recoverAction = { refresh() })
})
}
}
open class CommonDispatcher(val provider: DispatcherProvider) {
fun errors() = provider.errorDispatcher.errorObservable
fun onError(action: Any, cause: Throwable, extras: Any? = null,
recoverAction: (() -> Unit)? = null) =
provider.errorDispatcher.onError(action, cause, extras, recoverAction)
}
*OMJOF'VODUJPOTCZ,PUMJO