Reputation: 414
I have here an Observable, inwhich I combine two observables:
someOtherObservable
.switchMap {
Observables
.combineLatest(
RestClient
.getDataA()
.take(1),
RestClient
.getDataB()
.startWithItem(DataB())
)
}
.doOnNext { (dataA, dataB) ->
// do stuff...
}
.takeUntil(disposeObservable)
.subscribe()
and whereas my disposeObservable
is
initialiezed as:
val disposeObservable = disposeObservable()
and defined as:
@Composable
fun disposeObservable(): Observable<Unit> {
val subject = remember { PublishSubject.create<Unit>() }
DisposableEffect(Unit) {
onDispose { subject.onNext(Unit) }
}
return subject
}
for RestClient.getDataA().take(1)
I feel uncomfortable since there is no cleanup after take(1) !?
Does take(n) makes an automatic cleanup by itself? How would that code above look more clean?
If the outer .takeUntil(disposeObservable)
triggers, does this disposal is forwarded to the inner RestCLient.getData*
?
Upvotes: 0
Views: 82