You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
onShow and onHide are the only screen events. onHide is also called when a view comes in front. onPopped will be called when the screen is popped from the queue and can't be used in future.
This also means that if the developer store the fields in an instance variable and add it back to the queue it should throw an error.
Cases for it:
Leak analysis.
Allow for network requests which have the lifecycle of a screen.
onCreate/onPushed is not that important since we already have a constructor and with correct Rx multicasting, we can work around the limitations.
publicclassSomeScreen {
privatePublishSubject<NetworkResponse> responseSubject; // It can be non-reactive and just a state.privateObservable<NetworkRequest> request;
privateDisposablehideDispoable;
privateDisposablepoppedDisposable;
voidonPushed() {
request.subscribe(responseSubject); //dispose it onPopped() - only 1 network call for a screen;
}
voidonShow() {
hideDisposable = responseSubject.subscribe(_ -> { // Do your stuff }) // dispose it in onHide().
}
voidonHide() {
hideDisposable.clear();
}
voidonPopped() {
poppedDisposable.dispose();
// Leak analysis unless a developer wants to cache or magellan should throw an error.
}
}
The text was updated successfully, but these errors were encountered:
I think there is a case for onPushed() as well actually. Will definitely consider it. Any other idea for the names? Not completely sold on onPushed/onPopped, and onCreate/onDestroy would be confusing with the activity one.
onShow
andonHide
are the only screen events.onHide
is also called when a view comes in front.onPopped
will be called when the screen is popped from the queue and can't be used in future.This also means that if the developer store the fields in an instance variable and add it back to the queue it should throw an error.
Cases for it:
onCreate
/onPushed
is not that important since we already have a constructor and with correct Rx multicasting, we can work around the limitations.The text was updated successfully, but these errors were encountered: