Skip to content
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

Added discardSavedState argument to SavedStateRegistryOwner#stateKeeper extension function #131

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Added discardSavedState argument to SavedStateRegistryOwner#stateKeep…
…er extension function
  • Loading branch information
arkivanov committed Nov 30, 2023
commit aad37c8f9f42db5e2515a9d55f672e0fcc23b4c5
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
)