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

If Subscriber was unsubscribed once it won't receive onNext next time somebody will subscribe using it #1535

Closed
lexer opened this issue Jul 30, 2014 · 2 comments

Comments

@lexer
Copy link

lexer commented Jul 30, 2014

private Subscriber<Location> onLocationUpdated = new Subscriber<Location>() {
    @Override
    public void onNext(Location location) {
       // never called when was resumed after pause
    }
    ...
}

Subscription subscription = Subscriptions.empty();
void onResume() {
    subscription = locationService.observe().subscribe(onLocationUpdated);
}

void onPause() {
    subscription.unsubscribe();
}

I have a class field with subscriber implementation. When my UI resumed I subscribe using that subscriber on location updates. When UI is paused I unsubscribe.

Subscriber is field is not destroyed when UI is paused and should be reused for subscribe on UI resume. Unfortunately onNext will be never called.

Guess this related to this fix #1409.

@benjchristensen
Copy link
Member

A Subscriber should not be reused. It will not work because it is a Subscription and once unsubscribed is done.

Use an Observer instead if you want to reuse it.

@lexer
Copy link
Author

lexer commented Jul 30, 2014

Got it!

@lexer lexer closed this as completed Jul 30, 2014
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