-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable RememberObserver to work with rememberRetained (#1210)
This PR manually calls `RememberObserver` calls as appropriate when used in `rememberRetained`. The semantics of `rememberRetained` are obviously different to `remember`, so we call them at different times: - `onRemembered` will be called the first time that the retained item is first `remember`ed. The difference here is that we will **not** call `onRemembered` again once a the object is restored and remembered back into composition. - `onForgotten` will be called only once the retained state is cleared from both composition and any retained registries. - Thus, the logical lifecycle is maintained of created (`onRemembered` called), through to being no longer retained/remembered (`onForgotten` called). - We do not call `onAbandoned` as retained state doesn't meet the contract of the function. I did think about creating a `RetainedObserver` interface, but figured that using the existing `RememberObserver`, even with slightly different semantics, is a better solution. This has a variety of use-cases, but I have been playing around with a `rememberRetainedCorotineScope` in Tivi: chrisbanes/tivi#1763
- Loading branch information
1 parent
bcd2f75
commit 4a29084
Showing
3 changed files
with
76 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters