Interface StorageService


public interface StorageService
Interface implemented to provide the state storage and retrieval services.
  • 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

      void scheduleCommit(@Nonnull SafeProcedure commitTriggerAction)
      Method invoked when state has changed. The storage service is expected to invoke the commitTriggerAction.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

      @Nonnull Object encodeState(@Nonnull Map<String,Object> state, @Nonnull TypeConverter converter)
      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

      @Nonnull Map<String,Object> decodeState(@Nonnull Object encoded, @Nonnull TypeConverter converter)
      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.