DatumManager<T extends DatumEntityBase> class

Mixed-in types
Available extensions

Constructors

DatumManager({required LocalAdapter<T> localAdapter, required RemoteAdapter<T> remoteAdapter, DatumConflictResolver<T>? conflictResolver, required DatumConnectivityChecker connectivity, DatumConfig<T>? datumConfig, DatumLogger? logger, List<DatumObserver<T>>? localObservers, List<DatumMiddleware<T>>? middlewares, List<GlobalDatumObserver>? globalObservers, DatumSyncRequestStrategy? syncRequestStrategy})

Properties

config DatumConfig<T>
final
currentStatus DatumSyncStatusSnapshot
The most recent snapshot of the manager's sync status.
no setter
eventStream Stream<DatumSyncEvent<T>>
Public event streams
no setter
hashCode int
The hash code for this object.
no setterinherited
health Stream<DatumHealth>
A stream of the manager's current health status.
no setter
isDisposed bool
Returns true if the object has been disposed.
no setterinherited
isInitialized bool
no setter
localAdapter LocalAdapter<T>
final
onConflict Stream<ConflictDetectedEvent<T>>
no setter
onDataChange Stream<DataChangeEvent<T>>
no setter
onNextSyncTimeChanged Stream<DateTime?>
no setter
onSyncCompleted Stream<DatumSyncCompletedEvent<T>>
no setter
onSyncError Stream<DatumSyncErrorEvent<T>>
no setter
onSyncProgress Stream<DatumSyncProgressEvent<T>>
no setter
onSyncStarted Stream<DatumSyncStartedEvent<T>>
no setter
onUserSwitched Stream<UserSwitchedEvent<T>>
no setter
queueManager QueueManager<T>
Exposes the queue manager for central orchestration.
no setter
remoteAdapter RemoteAdapter<T>
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
watchNextSyncDuration Stream<Duration?>
A stream that emits the Duration until the next scheduled auto-sync.
no setter
watchNextSyncTime Stream<DateTime?>
A stream that emits the DateTime of the next scheduled auto-sync.
no setter

Methods

checkHealth() Future<DatumHealth>
Performs a health check on the local and remote adapters and updates the health stream with the result.
delete({required String id, required String userId, DataSource source = DataSource.local, bool forceRemoteSync = false}) Future<bool>
Deletes an entity by its ID from all local and remote adapters.
deleteAndSync({required String id, required String userId, DatumSyncOptions<DatumEntityBase>? syncOptions}) Future<(bool, DatumSyncResult<T>)>
Deletes an entity locally and immediately triggers a synchronization.
dispose() Future<void>
Releases all resources held by the manager and its adapters.
override
ensureNotDisposed() → void
Throws a StateError if the object has been disposed.
inherited
fetchRelated<R extends DatumEntityBase>(T parent, String relationName, {DataSource source = DataSource.local}) Future<List<R>>
Fetches related entities for a given parent entity.
getLastSyncResult(String userId) Future<DatumSyncResult<T>?>
Retrieves the result of the last synchronization for a user from local storage.
getNextSyncDuration() Future<Duration?>

Available on DatumManager<T>, provided by the DatumManagerAutoSyncInfo extension

Gets the Duration until the next scheduled auto-sync as a Future.
getNextSyncTime() Future<DateTime?>

Available on DatumManager<T>, provided by the DatumManagerAutoSyncInfo extension

Gets the DateTime of the next scheduled auto-sync as a Future.
getPendingCount(String userId) Future<int>
Returns the number of pending synchronization operations for the user.
getPendingOperations(String userId) Future<List<DatumSyncOperation<T>>>
Returns a list of pending synchronization operations for the user.
getStorageSize({String? userId}) Future<int>
Gets the current storage size in bytes from the local adapter.
initialize() Future<void>
Initializes the manager and its adapters. Must be called before any other methods.
manageController(StreamController controller) → void
Registers a StreamController to be automatically closed on dispose.
inherited
manageSubscription(StreamSubscription subscription) → void
Registers a StreamSubscription to be automatically cancelled on dispose.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pause() → void
pauseSync() → void
Pauses all synchronization activity for this manager.
push({required T item, required String userId, DataSource source = DataSource.local, bool forceRemoteSync = false}) Future<T>
pushAndSync({required T item, required String userId, DatumSyncOptions<DatumEntityBase>? syncOptions}) Future<(T, DatumSyncResult<T>)>
Saves an entity locally and immediately triggers a synchronization.
query(DatumQuery query, {required DataSource source, String? userId}) Future<List<T>>
Executes a one-time query against the specified data source.
read(String id, {String? userId}) Future<T?>
Reads a single entity by its ID from the primary local adapter.
readAll({String? userId}) Future<List<T>>
Reads all entities from the primary local adapter.
resume() → void
resumeSync() → void
Resumes synchronization activity for this manager.
saveMany({required List<T> items, required String userId, bool andSync = false, DatumSyncOptions<DatumEntityBase>? syncOptions}) Future<List<T>>
startAutoSync(String userId, {Duration? interval}) → void
Starts automatic periodic synchronization for the specified user.
stopAutoSync({String? userId}) → void
Stops automatic synchronization for one or all users.
switchUser({required String? oldUserId, required String newUserId, UserSwitchStrategy? strategy}) Future<DatumUserSwitchResult>
Switches the active user with configurable handling of unsynced data.
synchronize(String userId, {DatumSyncOptions<DatumEntityBase>? options, DatumSyncScope? scope}) Future<DatumSyncResult<T>>
toString() String
A string representation of this object.
inherited
updateAndSync({required T item, required String userId, DatumSyncOptions<DatumEntityBase>? syncOptions}) Future<(T, DatumSyncResult<T>)>
Updates an entity locally and immediately triggers a synchronization.
watchAll({String? userId, bool includeInitialData = true}) Stream<List<T>>?
Watches all entities from the local adapter, emitting a new list on any change.
watchAllPaginated(PaginationConfig config, {String? userId}) Stream<PaginatedResult<T>>?
Watches a paginated list of items. Returns null if the adapter does not support reactive queries.
watchById(String id, String? userId) Stream<T?>?
Watches a single entity by its ID, emitting the item on change or null if deleted. Returns null if the adapter does not support reactive queries.
watchQuery(DatumQuery query, {String? userId}) Stream<List<T>>?
Watches a subset of items matching a query. Returns null if the adapter does not support reactive queries.
watchRelated<R extends DatumEntityBase>(T parent, String relationName) Stream<List<R>>?
Reactively watches related entities for a given parent entity.
watchStorageSize({String? userId}) Stream<int>
Reactively watches the storage size in bytes from the local adapter.

Operators

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