-
Notifications
You must be signed in to change notification settings - Fork 90
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
Renderable lifecycle #68
Comments
+1 |
React like events would be welcome (componentDidMount, componentWillMount, componentWillUpdate, componentDidUpdate) |
+1 for React-like events |
+1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Anvil allows writing components as lambdas or as RenderableViews. Some components may be stateful and may depent on the hosting Activity/Fragment/... lifecycle.
Currenclty, RenderableView has onAttachedToWindow and onDetachedFromWindow hooks, but they are not helpful for saving/restoring instance state, for handling pause/resume events etc.
How about adding a few functions to BaseDSL that would allow to register a listener to a certain type of lifecycle events, e.g:
BaseDSL would keep a static list of weak references to all listeners, also Anvil would provide certain functions to emit lifecycle events, e.g.
Anvil.pause()
,Anvil.resume()
,Anvil.save()
,Anvil.restore()
.I'm not sure which lifecycle events should be supports and about details of the implementation, but ideally it should support Activities, Fragments and Conductor controllers.
Other libraries provide either a full set of events (RxLifeCycle, Navi etc) - https://github.com/trello/navi/blob/master/navi/src/main/java/com/trello/navi/Event.java
CREATE, START, RESUME, PAUSE, STOP, DESTROY (Activity lifecycle), ATTACH, CREATE, CREATE_VIEW, START, RESUME, PAUSE, STOP, DESTROY_VIEW, DESTROY, DETACH (Fragment lifecycle)
or a small subset of those (see: Conductor).The text was updated successfully, but these errors were encountered: