rana
rana

Reputation: 1862

Android Rxlifecycle with multiple Observers

I am new to RxLifecycle .We are moving from CompositeSubscription to manage auto unsubcribe to rely on RxLifecycle. I have a question. If I have 7 network calls and each one is tracked using an individual Subscriptions, Can any of you tell me if we can use the same BehaviourSubject from the RxFragment using bindUntilEvent()or do I have to define 7 BehaviourSubject for each Subscription Observables ?

Upvotes: 1

Views: 409

Answers (1)

rana
rana

Reputation: 1862

I figured out from their source code . As you can see below , they are newing up each time when I call bindUntilEvent(). So if we implement ActivityLifecycleProvider or FragmentLifecycleProvider and call the same bindUntilEvent() should work fine for all Observables.

@NonNull
@CheckResult
public static <T, R> LifecycleTransformer<T> bindUntilEvent(@NonNull final Observable<R> lifecycle,
                                                            @NonNull final R event) {
    checkNotNull(lifecycle, "lifecycle == null");
    checkNotNull(event, "event == null");

    return new UntilEventObservableTransformer<>(lifecycle, event);
}

Upvotes: 1

Related Questions