Skip to content

Commit

Permalink
Merge pull request #131 from arkivanov/add-discardSavedState-arg
Browse files Browse the repository at this point in the history
Added discardSavedState argument to SavedStateRegistryOwner#stateKeeper extension function
  • Loading branch information
arkivanov committed Nov 30, 2023
2 parents 38352f7 + aad37c8 commit 164281a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions state-keeper/api/android/state-keeper.api
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
public final class com/arkivanov/essenty/statekeeper/AndroidExtKt {
public static final fun StateKeeper (Landroidx/savedstate/SavedStateRegistry;ZLkotlin/jvm/functions/Function0;)Lcom/arkivanov/essenty/statekeeper/StateKeeper;
public static synthetic fun StateKeeper$default (Landroidx/savedstate/SavedStateRegistry;ZLkotlin/jvm/functions/Function0;ILjava/lang/Object;)Lcom/arkivanov/essenty/statekeeper/StateKeeper;
public static final fun stateKeeper (Landroidx/savedstate/SavedStateRegistryOwner;Lkotlin/jvm/functions/Function0;)Lcom/arkivanov/essenty/statekeeper/StateKeeper;
public static synthetic fun stateKeeper$default (Landroidx/savedstate/SavedStateRegistryOwner;Lkotlin/jvm/functions/Function0;ILjava/lang/Object;)Lcom/arkivanov/essenty/statekeeper/StateKeeper;
public static final fun stateKeeper (Landroidx/savedstate/SavedStateRegistryOwner;ZLkotlin/jvm/functions/Function0;)Lcom/arkivanov/essenty/statekeeper/StateKeeper;
public static synthetic fun stateKeeper$default (Landroidx/savedstate/SavedStateRegistryOwner;ZLkotlin/jvm/functions/Function0;ILjava/lang/Object;)Lcom/arkivanov/essenty/statekeeper/StateKeeper;
}

public final class com/arkivanov/essenty/statekeeper/DefaultStateKeeperDispatcher$SavedState$Creator : android/os/Parcelable$Creator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,17 @@ 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,
discardSavedState = discardSavedState,
isSavingAllowed = isSavingAllowed
)

0 comments on commit 164281a

Please sign in to comment.