An approach to MVP/MVI using RxJava 2 & Dagger 2 (Part 2 of 2— One chain of events)
Frederico Sabino
777

Great article! I implemented a very similar architecture, only I used both a PublishSubject (like you) and a BehaviourSubject on the other end, like this.

disposable = uiEvents.compose(transformer).subscribe(uiModelBehaviourSubject)

I save this subscription and clear it on onCleared(), which makes me wonder, in your approach, shouldn’t you be doing something like?:

val disposable: Disposable? = null
val uiModelObservable: Observable<MainActivityUiModel> = uiEvents.compose(transformer).replay(1).autoConnect(0, { disposable = it })
override fun onCleared() {
super.onCleared()
disposable?.dispose()
}

I’m not an expert in RxJava this is genuine question.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.