RemoterClient class
Client that processes query actions and holds cache data
IMPORTANT
Client methods can be used anywhere in application
but generics from methods should not be omitted and should be same as the one used in widgets,
otherwise runtime errors will occur
For instance, in order to invalidate RemoterQuery<CatFacts>(remoterkey: "cat_facts")
,
client.invalidateQuery<CatFacts>("cat_facts")
should be called
All methods expects either T, RemoterData
Constructors
- RemoterClient({RemoterOptions? options})
- Client that processes query actions and holds cache data
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- options → RemoterOptions
-
Holds global options which is used on each query unless overriden
see RemoterOptions for more details
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
dispose(
) → void - Called to release all allocated resources
-
fetch<
T extends BaseRemoterData, S> (String key, {FutureOr< S> execute(RemoterParam? pageParam)?, RemoterOptions? options}) → Future<void> -
Executes given function and stores result in cache as entry with
key
Also this function saves given function to use in invalidateQuery and retry APIs Triggers background refetch if query has run before and is stale now Retries query if its status is RemoterStatus.errorexecute
can only be omitted if this function has been called before with anexecute
functionT
expects RemoterData or PaginatedRemoterData -
fetchNextPage<
T> (String key, [RemoterOptions? options]) → Future< void> -
Fetches next page of data with
key
if PaginatedRemoterData.hasNextPage of current data is trueT
expects type of data -
fetchPreviousPage<
T> (String key, [RemoterOptions? options]) → Future< void> -
Fetches previous page of data with
key
if PaginatedRemoterData.hasPreviousPage of current data is trueT
expects type of data -
getData<
T> (String key) → T? -
Return data from cache
T
expects RemoterData or PaginatedRemoterData type -
getListenersCount(
String key) → int? -
Gets count of current listeners for given
key
-
getStream<
T extends BaseRemoterData, S> (String key, [RemoterOptions? options]) → Stream< T> -
Returns new Stream which gets cache entry if exists as first data
T
expects RemoterData or PaginatedRemoterData type -
invalidateQuery<
T> (String key, [RemoterOptions? options]) → Future< void> -
Triggers a background fetch for given
key
if there is at least 1 listener Ignores staleTimeT
expects type of data -
isQueryStale(
String key, int staleTime) → bool -
Return if query is stale based on
staleTime
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
retry<
T> (String key, [RemoterOptions? options]) → Future< void> -
Retries failed query
Query should have status of RemoterStatus.error
T
expects type of data -
savePaginatedQueryFunctions(
String key, PaginatedQueryFunctions functions) → void - Stores functions for paginated queries of how to fetch new pages
-
setData<
T extends BaseRemoterData> (String key, T data) → void -
Sets data for entry with
key
Also notifies listeners with new stateT
expects RemoterData or PaginatedRemoterData type -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited