-
Notifications
You must be signed in to change notification settings - Fork 65
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
Add rememberRetainedSaveable #1305
Add rememberRetainedSaveable #1305
Conversation
Can we do this? #722 (comment) |
85249fb
to
8f784f0
Compare
Pushed up two commits for comparison: 7872adb replaces the existing 8f784f0 effectively adds a |
8f784f0
to
15466a3
Compare
Think the Not a huge fan of |
I like keep, but feel like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had some stale comments that I apparently never sent!
circuit-retained/src/commonMain/kotlin/com/slack/circuit/retained/RememberRetained.kt
Outdated
Show resolved
Hide resolved
circuit-retained/src/commonMain/kotlin/com/slack/circuit/retained/RememberRetained.kt
Show resolved
Hide resolved
circuit-retained/src/commonMain/kotlin/com/slack/circuit/retained/RememberRetained.kt
Show resolved
Hide resolved
circuit-retained/src/commonMain/kotlin/com/slack/circuit/retained/RememberRetained.kt
Show resolved
Hide resolved
* It behaves similarly to [remember], but the stored value will survive configuration changes, such | ||
* as a screen rotation. | ||
* | ||
* Use this overload if you remember a mutable state. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you elaborate a bit on this? I think I'm learning something new here heh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated - this matches the overloads of rememberSaveable
, where it can be convenient to just write the Saver
for the thing inside of mutableStateOf
, instead of the whole MutableState
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL!
circuit-retained/src/commonMain/kotlin/com/slack/circuit/retained/RememberRetained.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One nit around a param name, otherwise I think with the nullable Saver
change this can be good to go!
Adds a
rememberRetainedSaveable
variant that participates in bothRetainedStateRegistry
andSaveableStateRegistry
restoration.The logic is the following upon
rememberRetainedSaveable
entering composition:RetainedStateRegistry
andSaveableStateRegistry
, if availableThe
RememberObserver
behavior is duplicated from therememberRetained
behavior.