HiveOperationsPersistence<T> class

Durable persistence engine for failed operations using Hive. This is most suited for write operations which you want to try again later, such as to provide offline support which queues up writes for when connectivity is restored; even if that is after a fresh launch of the app.

Constructors

HiveOperationsPersistence({required String name, required Future<void> hiveInit, required Bindings<T> bindings, HiveInterface? hive, Scheduler scheduler = const RealScheduler()})
Durable persistence engine for failed operations using Hive. This is most suited for write operations which you want to try again later, such as to provide offline support which queues up writes for when connectivity is restored; even if that is after a fresh launch of the app.

Properties

bindings → Bindings<T>
Serialization bindings for T.
final
hashCode int
The hash code for this object.
no setterinherited
hiveInit Future<void>
Future which should resolve when Hive is initialized.
final
isNotReady bool
Returns true if this object has not yet successfully achieved readiness.
no setterinherited
isReady bool
Returns true if this object has successfully achieved readiness.
no setterinherited
name String
Unique base name for the Hive boxes.
final
readiness ↔ Readiness
Cache of whether this object is ready. Set by the completer.
getter/setter pairinherited
ready Future<void>
Resolves when readiness is achieved, or immediately if it has already been achieved.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scheduler → Scheduler
Scheduler for retry timers.
final

Methods

close() Future<void>
Releases all resources.
getSavedOperations() Future<List<Operation<T>>>
Retrieves all Operation passed to save still in persistence. These should be fully removed from persistence because connectivity has now been restored; and if they fail again for some reason, they should be passed back to save.
initialize() → void
Calls performInitialization with extra bookkeeping. Descendant classes should implement performInitialization but then invoke initialize.
inherited
markReady(void obj) → void
Marks this object as ready. Implementing classes should call this function when they are ready, presumably either in or because of some side effect of performInitialization.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onRetryOperation() Stream<Operation<T>>
Stream of Operations whose time to retry has come. It is the job of the RetryPolicy to subscribe to this stream and ferry each emitted Operation back to the SourceList.
performInitialization() FutureOr<void>
Classes using ReadinessMixin should implement this method to perform any necessary initialization. Implementations of this method should call markReady and pass in any special value for T that should be returned from ready.
resetReadiness() → void
Resets any established readiness, if for example a dependency of this object has also lost readiness.
inherited
save(Operation<T> operation) Future<void>
Saves a Operation to retry later. This operation will not be automatically retried; it is up to the caller to schedule retries.
schedule(Operation<T> operation, {Duration? maxWait}) Future<void>
Schedules a Operation to be retried later. Exponential backoff is used if the operation has failed multiple times.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited