Fernando Raviola
Jul 29, 2017 · 1 min read

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? = nullval 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.

    Fernando Raviola

    Written by

    Software engineer, Android enthusiast, Traveller

    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade