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 functions

java-static StateStore

Creates a StateStore.

java-static Int

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

Unit

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

Public functions

create

Added in 1.0.0
java-static fun create(
    initialState: (Mutable)Map<AppDataKey<Any!>!, DynamicDataBuilders.DynamicDataValue<Any!>!>
): StateStore

Creates a StateStore.

Throws
java.lang.IllegalStateException

if number of initialState entries is greater than getMaxStateEntryCount.

getMaxStateEntryCount

Added in 1.0.0
java-static fun getMaxStateEntryCount(): Int

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
fun setAppStateEntryValues(
    newState: (Mutable)Map<AppDataKey<Any!>!, DynamicDataBuilders.DynamicDataValue<Any!>!>
): Unit

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.