Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LifecycleObservable not unsubscribing after mergeWith #131

Closed
david-hoze opened this issue Feb 10, 2015 · 1 comment
Closed

LifecycleObservable not unsubscribing after mergeWith #131

david-hoze opened this issue Feb 10, 2015 · 1 comment

Comments

@david-hoze
Copy link

Hi, I'm running this code (version 0.24)

System.out.println("testMergeLifecycleObservable -------------------------------");

Observable<Long> source1 =
        LifecycleObservable.bindActivityLifecycle(lifecycle(),
                Observable.interval(5,TimeUnit.SECONDS)
                        .doOnUnsubscribe(() -> {System.out.println("source1 unsubscribe");})
        );

Observable<Long> source2 =
        LifecycleObservable.bindActivityLifecycle(lifecycle(),
                Observable.interval(5,TimeUnit.SECONDS)
                        .doOnUnsubscribe(() -> {System.out.println("source2 unsubscribe");})
        );

source1.mergeWith(source2)
        .flatMap(e -> {return Observable.just(e.toString());})
        .doOnUnsubscribe(() -> {System.out.println("final observable unsubscribe");})
        .subscribe(System.out::println);

and getting this output (after rotating the screen in the middle):

testMergeLifecycleObservable -------------------------------
0
0
1
1
2
2
source1 unsubscribe
source2 unsubscribe
testMergeLifecycleObservable -------------------------------
0
0
1
1

which means that the observable after the flatMap operator was not unsubscribed from..

@JakeWharton
Copy link
Contributor

LifecycleObservable has been removed for future releases as part of #172. While it might come back in some form, you're much better off either emitting specific events for the lifecycle or explicitly unsubscribing in the callback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants