LocalSource<T> class

Flavor of Source which is entirely on-device.

Internally, this class's entire job is to coordinate its various ExpiringCache objects.

Inheritance
Implementers

Constructors

LocalSource({required ExpiringCache<T> itemsCache, required ExpiringCache<Set<String>> requestCache, required SourceCache<Set<String>> paginatedRequestCache, Duration? ttl, Bindings<T>? bindings})
Flavor of Source which is entirely on-device.

Properties

bindings Bindings<T>
All meta information about T necessary to plug arbitrary data types into a Repository.
getter/setter pairinherited
hasBindings bool
Proxy getter for whether bindings has been initialized, either by being passed in via this constructor or by being set by the SourceList.
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sourceType SourceType
Indicator for whether this Source loads data from a store on-device, or off-device.
getter/setter pairoverride-getter
supportedOperations Set<SourceOperationType>
The operations supported by this loader instance. Defaults to standard CRUD operations.
no setterinherited
ttl Duration?
Duration after which the data should be considered stale. Stale data will not be returned, and will be deleted when requested. There is no other periodic process to remove stale data - if it is never requested again, it will remain in storage indefinitely.
final

Methods

clear() Future<void>
Removes all data from the local persistence.
clearForRequest(RequestDetails details) Future<void>
Clears this request from the request cache.
delete(DeleteOperation<T> operation) Future<DeleteResult<T>>
Clears an item with the given DeleteOperation.itemId if one exists.
override
deleteIds(Set<String> ids) Future<void>
Removes these Ids from storage anywhere they may exist, which is why no RequestDetails are needed.
getById(ReadOperation<T> operation) Future<ReadResult<T>>
Loads the instance of T whose primary key is found at ReadOperation.itemId.
override
getByIds(ReadByIdsOperation<T> operation) Future<ReadListResult<T>>
Loads all instances of T whose primary key is in the set at ReadByIdsOperation.itemIds.
override
getItems(ReadListOperation<T> operation) Future<ReadListResult<T>>
Loads all instances of T that satisfy any filtes or pagination on ReadListOperation.details.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notReferencedByAnyRequests(Set<String> keys) Future<Set<String>>
Returns the subset of keys that are not referenced by any requests in the cache. This is used to detect whether keys orphaned by a specific write are in fact globally orphaned and should be deleted, or should merely be deleted from that specific request.
setItem(WriteOperation<T> operation) Future<WriteResult<T>>
Persists WriteOperation.item.
override
setItems(WriteListOperation<T> operation) Future<WriteListResult<T>>
Persists all WriteListOperation.items.
override
supports(SourceOperationType type) bool
Returns whether this instance supports the given SourceOperationType.
inherited
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

builders<T>({required SourceCache<T> itemCache(String name), required SourceCache<Set<String>> stringSetCache(String name), required SourceCache<DateTime> dateTimeCache(String name), Bindings<T>? bindings, Duration? ttl}) LocalSource<T>
Convenience constructor which assembles the inner caches for you.