prefetch<ResultType> method
use to programmatically fetch a query model and create the relative stream if not exist if the stream already exist it will do nothing
Implementation
void prefetch<ResultType>(QueryModel<dynamic, ResultType> query) {
if (_queryCache.containsKey(query.key)) {
if (_queryCache[query.key]!.stream.value is QueryError) {
_queryCache[query.key]!.stream.add(QueryLoading());
_fetchData<ResultType>(query.fetch, _queryCache[query.key]!.stream);
}
return;
}
_queryCache[query.key] = QueryStream(
(BehaviorSubject stream) {
stream.add(QueryLoading());
return _fetchData(query.fetch, stream);
},
);
}