DestructiveLocalSyncFromRemoteMixin<T extends OfflineFirstModel> mixin

Provides an extended get method to support remote syncs that override local data. For example, if two models exist in the remoteProvider but three exist in sqliteProvider and memoryCacheProvider, the extra model is removed from the local providers when #get:forceLocalSyncFromRemote is true or when destructiveLocalSyncFromRemote is invoked.

Using this mixin and its methods requires that the data from the remoteProvider should not be paginated and complete from a single request.

Superclass Constraints

Properties

autoHydrate bool
Refetch results in the background from remote source when any request is made. Defaults to false.
finalinherited
hashCode int
The hash code for this object.
no setterinherited
logger → Logger
User for low-level debugging. The logger name can be defined in the default constructor; it defaults to OfflineFirstRepository.
finalinherited
memoryCacheProvider → MemoryCacheProvider
The first data source to speed up otherwise taxing queries. Only caches specified models.
finalinherited
migrationManager → MigrationManager
finalinherited
remoteProvider → Provider<Model>
The data source that data is pushed to and from.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sqliteProvider → SqliteProvider
The local data source utilized before every operation.
finalinherited
subscriptions Map<Type, Map<Query?, StreamController<List<T>>>>
finalinherited

Methods

applyPolicyToQuery(Query? query, {OfflineFirstDeletePolicy? delete, OfflineFirstGetPolicy? get, OfflineFirstUpsertPolicy? upsert}) Query?
As some remote provider's may utilize an OfflineFirstPolicy from the request, this composes the policy to the query (such as in the providerArgs).
inherited
delete<TModel extends RepositoryModel>(TModel instance, {OfflineFirstDeletePolicy policy = OfflineFirstDeletePolicy.optimisticLocal, Query? query}) Future<bool>
Remove a model from SQLite and the remoteProvider
inherited
destructiveLocalSyncFromRemote<TModel extends T>({Query? query}) Future<List<TModel>>
When invoked, local instances that exist in sqliteProvider and memoryCacheProvider but do not exist in the remoteProvider are destroyed. The data from the remoteProvider should not be paginated and must be complete from a single request.
exists<TModel extends RepositoryModel>({Query? query}) Future<bool>
Check if a TModel is accessible locally. First checks if there's a matching query in memoryCacheProvider and then check sqliteProvider. Does not query remoteProvider.
inherited
get<TModel extends T>({bool forceLocalSyncFromRemote = false, OfflineFirstGetPolicy policy = OfflineFirstGetPolicy.awaitRemoteWhenNoneExist, Query? query, bool seedOnly = false}) Future<List<TModel>>
Load association from SQLite first; if the TModel hasn't been loaded previously, fetch it from remoteProvider and hydrate SQLite. For available query providerArgs see remoteProvider#get SqliteProvider.get.
override
getAssociation<TModel extends RepositoryModel>(Query query) Future<List<TModel>?>
Used exclusively by the OfflineFirstAdapter. If there are no results, returns null.
inherited
getBatched<TModel extends RepositoryModel>({int batchSize = 50, OfflineFirstGetPolicy policy = OfflineFirstGetPolicy.awaitRemoteWhenNoneExist, Query? query, bool seedOnly = false}) Future<List<TModel>>
Get all results in series of batchSizes (defaults to 50). Useful for large queries or remote results.
inherited
hydrate<TModel extends RepositoryModel>({bool deserializeSqlite = true, Query? query}) Future<List<TModel>>
Fetch and store results from remoteProvider into SQLite and the memory cache.
inherited
initialize() Future<void>
Prepare the environment for future repository functions. It is recommended to call this method within a StatefulWidget's initState to ensure it is only invoked once. It is not automatically invoked.
inherited
migrate() Future<void>
Update SQLite structure with only new migrations.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifySubscriptionsWithLocalData<TModel extends RepositoryModel>({bool notifyWhenEmpty = true}) Future<void>
Iterate through subscriptions after an upsert and notify any subscribe listeners.
inherited
reset() Future<void>
Destroys all local records - specifically, memoryCache and sqliteProvider's data sources.
inherited
storeRemoteResults<TModel extends RepositoryModel>(List<TModel> models, {bool shouldNotify = true}) Future<List<TModel>>
Save response results to SQLite.
inherited
subscribe<TModel extends RepositoryModel>({OfflineFirstGetPolicy policy = OfflineFirstGetPolicy.localOnly, Query? query}) Stream<List<TModel>>
Listen for streaming changes when the sqliteProvider is upserted. This method utilizes remoteProvider's get.
inherited
toString() String
A string representation of this object.
inherited
upsert<TModel extends RepositoryModel>(TModel instance, {Query? query, OfflineFirstUpsertPolicy policy = OfflineFirstUpsertPolicy.optimisticLocal}) Future<TModel>
Send a model to remoteProvider and hydrate.
inherited

Operators

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