preloadInBackground<T> method
Stream<PreloadOperation>
preloadInBackground<T>({
- required Map<
String, Future< dataProviders,T> Function()> - CachePolicy? policy,
- Set<
String> ? tags, - int parallelism = 5,
- void onProgress(
- String key,
- PreloadStatus status,
- double progress
Preloads data into the cache in the background.
This method returns immediately and performs the preloading in the background.
The dataProviders
parameter is a map where the keys are the cache keys and the values are
functions that return the data to be cached.
The policy
parameter can be used to set a cache policy for all the data.
The tags
parameter can be used to associate tags with all the data.
The parallelism
parameter determines how many items to preload in parallel.
The onProgress
parameter is a callback that is called when an item is preloaded.
Returns a stream of preload operations.
Implementation
Stream<PreloadOperation> preloadInBackground<T>({
required Map<String, Future<T> Function()> dataProviders,
CachePolicy? policy,
Set<String>? tags,
int parallelism = 5,
void Function(String key, PreloadStatus status, double progress)?
onProgress,
}) {
// Start preloading in the background
preload(
dataProviders: dataProviders,
policy: policy,
tags: tags,
parallelism: parallelism,
onProgress: onProgress,
);
// Return the stream of preload operations
return preloadEvents;
}