Repository<T> class

Data abstraction most likely to be exposed to other layers of the application. Subclasses of this are where domain-specific logic should live.

Mixed-in types
Implementers

Constructors

Repository(SourceList<T> sourceList, {String? loggerName, DateTime getTime()?})
Data abstraction most likely to be exposed to other layers of the application. Subclasses of this are where domain-specific logic should live.

Properties

getTime DateTime Function()
Reads the wall clock to annotate operations.
final
hashCode int
The hash code for this object.
no setterinherited
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
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
sourceList SourceList<T>
Data loader within a Repository which can cascade through a list of data sources, treating each as a write-through cache.
final

Methods

clear() Future<void>
Clears all local data. Does not delete anything from any remote sources.
clearForRequest(RequestDetails details) Future<void>
Clears all local data cached against this request.
close() → void
Releases any open resources like stream subscriptions.
delete(String id, {RequestDetails? details}) Future<void>
Removes the item associated with the given id from persistence.
generateOperationId() String
Generates a unique operation ID, which defaults to v7 to preserve chronological ordering for logging and debugging purposes.
getById(String id, {RequestDetails? details}) Future<T?>
Loads an item by the given id if it exists.
getByIds(Set<String> ids, {RequestDetails? details}) Future<(List<T>, Set<String>)>
Loads all items in the given Id set. If any Ids were not fulfilled, they are included in missingIds.
getItems({RequestDetails? details}) Future<List<T>>
Loads all items that match the given request details, or the default RequestDetails.read object if not given.
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
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.
override
resetReadiness() → void
Resets any established readiness, if for example a dependency of this object has also lost readiness.
inherited
setItem(T item, {RequestDetails? details}) Future<T?>
Persists the given item and returns the saved value if the write was successful.
setItems(Iterable<T> items, {RequestDetails? details}) Future<List<T>>
Persists all items.
toString() String
A string representation of this object.
override
watch(String id, {RequestDetails? details}) Stream<T?>
Opens a live stream for the item with the given id.
watchByIds(Set<String> ids, {RequestDetails? details}) Stream<(List<T>, Set<String>)>
Opens a live stream for all items in the given Id set.
watchList({RequestDetails? details}) Stream<List<T>>
Opens a live stream for all items that match the given request details, or the default RequestDetails.read object if not given.

Operators

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