Package arez.persist.runtime
Interface StorageService
public interface StorageService
Interface implemented to provide the state storage and retrieval services.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classAn entry containing the state for a particular component. -
Method Summary
Modifier and TypeMethodDescriptionvoidInvoked by the store to save the state to the storage service.decodeState(Object encoded, TypeConverter converter) Decode state from backend storage form.voiddispose()Dispose the service.encodeState(Map<String, Object> state, TypeConverter converter) Encode state in a way that makes storage to the backend easier.voidRestore state from the service into the specified state parameter.voidscheduleCommit(SafeProcedure commitTriggerAction) Method invoked when state has changed.
-
Method Details
-
dispose
void dispose()Dispose the service. The service may release any resources no longer required after dispose has been called. It is expected that no other methods will be invoked after this method has been invoked. -
scheduleCommit
Method invoked when state has changed. The storage service is expected to invoke thecommitTriggerAction.call()method when service wants to commit changes to the service. This is likely to be invoked many times in quick succession and it is up to the storage service to decide how to batch up the changes and thus when to schedule the commit.- Parameters:
commitTriggerAction- the action to invoke when a commit should be triggered.
-
commit
Invoked by the store to save the state to the storage service. The map contains scopes, mapped to component types, mapped to component ids, map to instance data for that component.- Parameters:
state- the state to store.
-
restore
Restore state from the service into the specified state parameter.- Parameters:
state- the map in which to store data retrieved from the service.
-
encodeState
Encode state in a way that makes storage to the backend easier. This is invoked when the state change occurs.- Parameters:
state- the component state.converter- the converter for the type.- Returns:
- the encoded form for this service.
-
decodeState
Decode state from backend storage form. This occurs on access to state.- Parameters:
encoded- the encoded component state.converter- the converter for the type.- Returns:
- the decoded form of component state.
-