Persistor class abstract
Abstract persistor that implements the base persistence batching, de-duping and locking of persistence operations. Exposes the public persistence APIs for persistence implementations to implement. See Persistor as an example implementation.
Constructors
-
Persistor.new({required Logger logger, void onPersist(Set<
Document> batch)?, void onClear(Set<Collection> collections)?, void onClearAll()?, void onHydrate(Json data)?, void onSync()?, PersistorSettings settings = const PersistorSettings(), Duration persistenceThrottle = const Duration(milliseconds: 100), DataStoreEncrypter? encrypter})
Properties
- encrypter → DataStoreEncrypter
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- logger → Logger
-
final
-
onClear
→ void Function(Set<
Collection> collections)? -
final
- onClearAll → void Function()?
-
final
- onHydrate → void Function(Json data)?
-
final
-
onPersist
→ void Function(Set<
Document> batch)? -
final
- onSync → void Function()?
-
final
- persistenceThrottle → Duration
-
The throttle for batching persisted documents. All documents updated within the throttle
duration are batched together into a single persist operation.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- settings → PersistorSettings
-
final
Methods
-
clear(
List< Collection> collections) → Future<void> - Clear function used to clear all documents under the given collections.
-
clearAll(
) → Future< void> - Clears all documents and removes all persisted data.
-
hydrate(
[List< StoreReference> ? refs]) → Future<Json> - Hydration function called to read data from persistence. If no entities are specified, then it hydrations all persisted data. if entities are specified, it hydrates only the data from the paths under those entities.
-
init(
) → Future< void> - Public APIs to be implemented by any Persistor extension like FilePersistor.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
persist(
List< Document> docs) → Future<void> - Persist function called with the bath of documents that have changed (including been deleted) within the last throttle window specified by the Persistor.persistenceThrottle duration.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- defaultKey → PersistorValueKey
-
The name of the default DataStore key.
final
Static Methods
-
current(
{void onPersist(Set< Document> batch)?, void onClear(Set<Collection> collections)?, void onClearAll()?, void onHydrate(Json data)?, void onSync()?, Duration persistenceThrottle = const Duration(milliseconds: 100), PersistorSettings settings = const PersistorSettings()}) → Persistor - Selects the persistor to use based on the current platform. By default, this is the FilePersistor for non-web platforms and the IndexedDBPersistor for web.
-
key<
T> (String value) → PersistorValueKey -
keyBuilder<
T> (String builder(DocumentSnapshot< T> snap)) → PersistorBuilderKey