Package arez.persist.runtime
Class Store
java.lang.Object
arez.persist.runtime.Store
The store that contains a cached copy of any state persisted.
The store is also responsible for committing state to a storage service when the state has changed.
The commit is typically an asynchronous process that occurs in another process so as not to block the
ui thread.
-
Method Summary
Modifier and TypeMethodDescriptionget(Scope scope, String type, String id, TypeConverter converter) Retrieve the state for a single component from the store.booleanReturn true if this service has been disposed.voidRemove the state for a single component from the store.voidSave the state for a single component to the store.
-
Method Details
-
save
public void save(@Nonnull Scope scope, @Nonnull String type, @Nonnull String id, @Nonnull Map<String, Object> state, @Nonnull TypeConverter converter) Save the state for a single component to the store. If the state value is empty this operation is effectively a remove. If any changes are made to the store as a result of this operation then a commit is scheduled.- Parameters:
scope- the scope in which the state is saved.type- the string that identifies the type of component.id- a string representation of the component id.state- the state to store.converter- the converter to use to encode state for storage.
-
remove
Remove the state for a single component from the store. If the state does not exist then this is a noop, otherwise a commit is scheduled.- Parameters:
scope- the scope in which the state is saved.type- the string that identifies the type of component.id- a string representation of the component id.
-
get
@Nullable public Map<String,Object> get(@Nonnull Scope scope, @Nonnull String type, @Nonnull String id, @Nonnull TypeConverter converter) Retrieve the state for a single component from the store. If the state does not exist then a null is returned.- Parameters:
scope- the scope in which the state is saved.type- the string that identifies the type of component.id- a string representation of the component id.converter- the converter to use to decode state from storage.- Returns:
- the component state if it exists, else null.
-
isDisposed
Return true if this service has been disposed. A disposed service should not be interacted with.- Returns:
- true if this service has been disposed, false otherwise.
- See Also:
-
dispose()
-