Skip to content

Commit

Permalink
Added discardSavedState argument to SavedStateRegistryOwner#stateKeep…
Browse files Browse the repository at this point in the history
…er extension function
  • Loading branch information
arkivanov committed Nov 30, 2023
1 parent f68fe2f commit cd5244c
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,15 @@ fun StateKeeper(
/**
* Creates a new instance of [StateKeeper] and attaches it to the AndroidX [SavedStateRegistry].
*
* @param discardSavedState a flag indicating whether any previously saved state should be discarded or not,
* default value is `false`.
* @param isSavingAllowed called before saving the state.
* When `true` then the state will be saved, otherwise it won't. Default value is `true`.
*/
fun SavedStateRegistryOwner.stateKeeper(isSavingAllowed: () -> Boolean = { true }): StateKeeper =
fun SavedStateRegistryOwner.stateKeeper(
discardSavedState: Boolean = false,
isSavingAllowed: () -> Boolean = { true },
): StateKeeper =
StateKeeper(
savedStateRegistry = savedStateRegistry,
isSavingAllowed = isSavingAllowed
Expand Down

0 comments on commit cd5244c

Please sign in to comment.