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

Confusion about restartables and the Activity lifecycle #141

Open
jrobinson3k1 opened this issue May 2, 2017 · 3 comments
Open

Confusion about restartables and the Activity lifecycle #141

jrobinson3k1 opened this issue May 2, 2017 · 3 comments
Labels

Comments

@jrobinson3k1
Copy link

I'm either confused on the wording of the Javadocs, or restartable is not behaving how I would expect. I'm using restartableLatestCache, which from dissecting the Javadocs indicates that it will emit the last onNext value each time it is started, plus any new onNext values if they are emitted in the future. A restartable will re-subscribe after a "process restart". I'm unsure exactly what entails a process restart, but I assumed that meant when an activity is being recreated for whatever reason.

However, a simple pause/resume of the activity via backgrounding the app and bringing it back to the foreground triggers the restartable to fire off its cached value without a subsequent call to start. I didn't think that would qualify as a "process restart".

So if someone would be so kind, could you explain to me if this is working as intended, and if so, qualify what a "process restart" means so I know what behavior to expect in the future? How could I achieve a "latestCache"-like result, but only if the Activity has been re-created (destroy/create)?

@konmik
Copy link
Owner

konmik commented May 2, 2017

Hi, have you seen this explanation?

https://github.com/konmik/nucleus/wiki/Restartables

@jrobinson3k1
Copy link
Author

That is helpful for understanding the differences between first, latestCache, and replay. My confusion is with understanding why an Activity pause/resume is re-emitting its cached value. After further inspection, I see that takeView() occurs during onResume() and dropView() occurs during onPause(). I'm not clear in what advantages are gained by attaching to these particular lifecycles, as the view has not been destroyed or reconfigured, it's just hidden.

I have found a way to get it to work as I would expect by moving presenterDelegate.onDropView() to onDestroy() and presenterDelegate.onResume() to onCreate(). But since I'm unsure of the design decision for using pause/resume over create/destroy, I'm not sure if I'm potentially breaking functionality by making this move.

@konmik
Copy link
Owner

konmik commented May 5, 2017

onDestroy is not guaranteed to be called

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

No branches or pull requests

2 participants