SavedStateKt
public final class SavedStateKt
Summary
Public methods |
|
|---|---|
static final @NonNull T |
<T extends Object> read(Calls the specified function |
static final @NonNull SavedState |
savedState(Builds a new |
static final @NonNull Bundle |
savedState( |
static final @NonNull SavedState |
savedState(Builds a new |
static final @NonNull T |
<T extends Object> write(Calls the specified function |
Public methods
read
public static final @NonNull T <T extends Object> read(
@NonNull SavedState receiver,
@NonNull Function1<@NonNull SavedStateReader, @NonNull T> block
)
Calls the specified function block with a SavedStateReader value as its receiver and returns the block value.
IMPORTANT: The SavedStateReader passed as a receiver to the block is valid only inside that function. Using it outside of the function may produce an unspecified behavior.
| Parameters | |
|---|---|
@NonNull Function1<@NonNull SavedStateReader, @NonNull T> block |
A lambda function that performs read operations using the |
| Returns | |
|---|---|
@NonNull T |
The result of the lambda function's execution. |
| See also | |
|---|---|
SavedStateReader |
|
SavedStateWriter |
savedState
public static final @NonNull SavedState savedState(
@NonNull Map<@NonNull String, Object> initialState,
@NonNull Function1<@NonNull SavedStateWriter, Unit> builderAction
)
Builds a new SavedState with the specified initialState, given as a Map of String keys and Any value.
Allows further modification of the state using the builderAction.
IMPORTANT: The SavedStateWriter passed as a receiver to the builderAction is valid only inside that function. Using it outside of the function may produce an unspecified behavior.
| Parameters | |
|---|---|
@NonNull Map<@NonNull String, Object> initialState |
An initial map of key-value pairs to populate the state. Defaults to an empty map. |
@NonNull Function1<@NonNull SavedStateWriter, Unit> builderAction |
A lambda function with a |
| Returns | |
|---|---|
@NonNull SavedState |
A |
savedState
public static final @NonNull Bundle savedState(
@NonNull Bundle initialState,
@NonNull Function1<@NonNull SavedStateWriter, Unit> builderAction
)
savedState
public static final @NonNull SavedState savedState(
@NonNull SavedState initialState,
@NonNull Function1<@NonNull SavedStateWriter, Unit> builderAction
)
Builds a new SavedState with the specified initialState, given as a SavedState instance.
Allows further modification of the state using the builderAction.
IMPORTANT: The SavedStateWriter passed as a receiver to the builderAction is valid only inside that function. Using it outside of the function may produce an unspecified behavior.
| Parameters | |
|---|---|
@NonNull SavedState initialState |
An initial |
@NonNull Function1<@NonNull SavedStateWriter, Unit> builderAction |
A lambda function with a |
| Returns | |
|---|---|
@NonNull SavedState |
A |
write
public static final @NonNull T <T extends Object> write(
@NonNull SavedState receiver,
@NonNull Function1<@NonNull SavedStateWriter, @NonNull T> block
)
Calls the specified function block with a SavedStateWriter value as its receiver and returns the block value.
IMPORTANT: The SavedStateWriter passed as a receiver to the block is valid only inside that function. Using it outside of the function may produce an unspecified behavior.
| Parameters | |
|---|---|
@NonNull Function1<@NonNull SavedStateWriter, @NonNull T> block |
A lambda function that performs write operations using the |
| Returns | |
|---|---|
@NonNull T |
The result of the lambda function's execution. |
| See also | |
|---|---|
SavedStateReader |
|
SavedStateWriter |