public final class StateStore


State storage for ProtoLayout, which also supports sending callback when data items change.

Note that this class is **not** thread-safe. Since ProtoLayout inflation currently happens on the main thread, and because updates will eventually affect the main thread, this whole class must only be used from the UI thread.

Summary

Public methods

static @NonNull StateStore

Creates a StateStore.

static int

Returns the maximum number for state entries allowed for this StateStore.

void

Sets the given app state, replacing the current app state.

Public methods

create

Added in 1.0.0
public static @NonNull StateStore create(
    @NonNull Map<AppDataKey<Object>, DynamicDataBuilders.DynamicDataValue<Object>> initialState
)

Creates a StateStore.

Throws
java.lang.IllegalStateException

if number of initialState entries is greater than getMaxStateEntryCount.

getMaxStateEntryCount

Added in 1.0.0
public static int getMaxStateEntryCount()

Returns the maximum number for state entries allowed for this StateStore.

The ProtoLayout state model is not designed to handle large volumes of layout provided state. So we limit the number of state entries to keep the on-the-wire size and state store update times manageable.

setAppStateEntryValues

Added in 1.0.0
@UiThread
public void setAppStateEntryValues(
    @NonNull Map<AppDataKey<Object>, DynamicDataBuilders.DynamicDataValue<Object>> newState
)

Sets the given app state, replacing the current app state.

Informs registered listeners of changed values, invalidates removed values.

Throws
java.lang.IllegalStateException

if number of state entries is greater than getMaxStateEntryCount. The state will not update and old state entries will stay in place.