StateStore
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 |
create(Creates a |
static int |
Returns the maximum number for state entries allowed for this |
void |
@UiThreadSets the given app state, replacing the current app state. |
Public methods
create
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
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
@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 |