MviBaseViewModel<BrowseIntent, BrowseUiViewState> { private var intentsSubject: PublishSubject<BrowseIntent> = PublishSubject.create() private val statesSubject: BehaviorSubject<BrowseUiViewState> = BehaviorSubject.create() init { intentsSubject .map(this::actionFromIntent) .compose(processor.actionProcessor) .scan<BrowseUiViewState>(BrowseUiViewState.idle(), reducer) .subscribe(statesSubject) } override fun processIntents(intents: Observable<BrowseIntent>) { intents.subscribe(intentsSubject) } override fun states(): Observable<BrowseUiViewState> { return statesSubject } }