SourceList<T> class
Data component which iteratively asks individual sources for an object.
Sources that originally fail to yield an object have it cached if a fallback source is able to yield it. SourceList should rarely be subclassed, as all of its operations are intended to be completely uniform across data types. If you are tempted to subclass SourceList, consider putting that special logic in the data type or feature's Repository instead.
The RequestType parameter on RequestDetails can be used to control which sources are asked, which is helpful when you want to force a cache read or cache miss.
To retry failed operations, supply a RetryPolicy, or use the default value which aims to provide reasonable defaults.
See also:
- RetryPolicy which controls how failed operations are retried.
- Inheritance
-
- Object
- DataContract<
T> - SourceList
- Mixed-in types
-
- ReadinessMixin<
void>
- ReadinessMixin<
Constructors
-
SourceList({required List<
Source< sources, required Bindings<T> >T> bindings, ConnectivityService? connectivityService, RetryPolicy<T> ? retryPolicy, DateTime getTime()?}) - Data component which iteratively asks individual sources for an object.
-
SourceList.empty(Bindings<
T> bindings) -
Testing-friendly constructor for wiring things up that don't actually
require a functioning SourceList.
factory
Properties
-
bindings
→ Bindings<
T> -
Holds meta-information for a subclass of data class, making it fully
pluggable within any subtype of DataContract.
final
- connectivityService → ConnectivityService?
-
Connectivity service for this SourceList. If this is supplied, then
operations which fail due to a device being offline are immediately
routed to the RetryPolicy class for triage.
final
- getTime ↔ DateTime Function()
-
Reads the wall clock to annotate operations.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- isNotReady → bool
-
Returns
trueif this object has not yet successfully achieved readiness.no setterinherited - isReady → bool
-
Returns
trueif 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
-
retryPolicy
→ RetryPolicy<
T> ? -
Retry policy for this SourceList. If this is supplied, then operations
which fail due to connectivity or server issues can be retried.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
sources
→ List<
Source< T> > -
Iterable of data Source objects which this SourceList will use to load
requested data.
final
Methods
-
checkConnectivity(
RequestDetails details) → Future< void> - Checks connectivity if a ConnectivityService is provided. If the device is offline, throws a NoConnectivityException.
-
clear(
) → Future< void> - Calls clear on all LocalSources.
-
clearForRequest(
RequestDetails details) → Future< void> - Clears all local data cached against this request.
-
close(
) → Future< void> - Closes the SourceList and releases any resources it holds.
-
delete(
DeleteOperation< T> operation) → Future<DeleteResult< T> > -
Clears an item with the given
DeleteOperation.itemIdif one exists.override -
getById(
ReadOperation< T> operation) → Future<ReadResult< T> > -
Loads the instance of
Twhose primary key is found atReadOperation.itemId.override -
getByIds(
ReadByIdsOperation< T> operation) → Future<ReadListResult< T> > -
Loads all instances of
Twhose primary key is in the set atReadByIdsOperation.itemIds.override -
getItems(
ReadListOperation< T> operation) → Future<ReadListResult< T> > -
Loads all instances of
Tthat satisfy any filtes or pagination onReadListOperation.details.override -
getSources(
{RequestType requestType = RequestType.global, bool reversed = false}) → Iterable< MatchedSource< T> > - Returns all sources that match a given RequestType. Unmatches sources are also returned with that indicator, so they can still be stored in a list of empty sources for the purposes of caching.
-
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
Tthat 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
-
sendMessage(
SendMessageOperation< T> operation) → Future<WriteResult< T> > -
Sends a message object (e.g. for patching or decoupled creations).
override
-
setItem(
WriteOperation< T> operation) → Future<WriteResult< T> > -
Persists
WriteOperation.item.override -
setItems(
WriteListOperation< T> operation) → Future<WriteListResult< T> > -
Persists all
WriteListOperation.items.override -
toString(
) → String -
A string representation of this object.
override
-
validate(
) → void - Checks for invalid configurations.
-
watch(
ReadOperation< T> operation) → Stream<ReadResult< T> > - Opens a live stream which will yield the current matching model periodically via a ReadResult.
-
watchByIds(
ReadByIdsOperation< T> operation) → Stream<ReadListResult< T> > - Opens a live stream which will yield the current matching models periodically via a ReadListResult.
-
watchList(
ReadListOperation< T> operation) → Stream<ReadListResult< T> > - Opens a live stream which will yield the current matching models periodically via a ReadListResult.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited