ApiSource<T> class

Subtype of Source which knows how to make network requests to load data.

Inheritance

Constructors

ApiSource({required RestApi restApi, Level logLevel = Level.OFF, String? resultsKey = 'results', Bindings<T>? bindings, ITimer? timer})
Subtype of Source which knows how to make network requests to load data.

Properties

api RestApi
Utility able to send network requests.
final
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
idsCurrentlyBeingFetched Set<String>
Set of Ids currently being loaded, but which have not yet been resolved.
getter/setter pair
loadedItems Map<String, Completer<T?>>
Id-keyed store of Completer instances which are individually resolved when a batch is returned from the server.
final
logLevel → Level
Controls the level of logging.
final
queuedIds Set<String>
Ids set to be loaded during the next batch.
getter/setter pair
resultsKey String?
If supplied, is used to extract the list of items from the response body of fetchItems if the payload is wrapped in a Map.
final
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.
no setteroverride
timer ITimer
Clock-aware object used to batch Ids.
final

Methods

delete(DeleteOperation<T> operation) Future<DeleteResult<T>>
Clears an item with the given DeleteOperation.itemId if one exists.
override
extractItemFromJsonResponse(JsonApiResultBody body) Json
Overrideable hook to extract the raw item payloads out of the response body.
extractItemsFromJsonResponse(JsonApiResultBody body) List<Json>
Overrideable hook to extract the raw item payloads out of the response body.
fetchItems(Params? params) Future<ApiResult>
Submits a network request for data.
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
hydrateItemResponse(ApiSuccess success) → T?
Deserializes the result of a network request into the actual object(s).
hydrateListResponse(ApiSuccess success) List<T>
Deserializes the results of a network request into the actual object(s).
loadDeferredIds() Future<void>
Submits any Ids currently in the queue for loading.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
queueId(String id) → void
Prepares an Id to be loaded in the next batch.
serializeIdsForQueryString(Set<String> ids) Params
Converts a set of Ids into a query parameter. This is a common query parameter format for this type of filter, but it can be overridden if needed for a given API.
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.
inherited

Operators

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