StreamRepository<K, V> class

Repository for resource management.

Constructors

StreamRepository.local({required CacheStorage<K, V> storage})
Creates repository for use as local data storage. Caches data in the passed CacheStorage.
StreamRepository.remote({required FetchData<K, V> fetch, CacheStorage<K, V>? storage, Duration? cacheDuration, CacheDurationResolver<K, V>? cacheDurationResolver})
Creates repository with providing fetch callback, typically used for REST API call. Caches data in the passed CacheStorage. The default is MemoryCacheStorage.

Properties

cacheDurationResolver CacheDurationResolver<K, V>
final
fetch FetchData<K, V>?
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
storage CacheStorage<K, V>
final

Methods

clear([K? key]) Future<void>
Clear, delete and dispose resource by key or all resources if a key not passed.
getAll() Future<List<V>>
Fetch all data from underlying storage.
invalidate(K key) Future<void>
Invalidate resource by key and reload.
invalidateAll() Future<void>
Invalidate all resources and reload.
load(K key, {bool? forceReload, void doOnStore(V)?, ResourceFetchArguments? fetchArguments, bool allowEmptyLoading = false}) Future<Resource<V>>
Same as stream, but waiting only for the first completed result.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
putValue(K key, V value) Future<void>
Put value directly in the storage.
stream(K key, {bool? forceReload, void doOnStore(V)?, ResourceFetchArguments? fetchArguments, bool allowEmptyLoading = false}) Stream<Resource<V>>
Creates a stream by key. It emits the cached data, then the fetch result if provided, and after that any changes to the resource due to reloading or invalidating the resource.
toString() String
A string representation of this object.
inherited
updateValue(K key, V? changeValue(V? value), {bool notifyOnNull = false}) Future<void>
Update or replace value by key directly in the storage.
watch() Stream<List<V>>
Stream of all stored entries that emits on any change of any resource.

Operators

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