fetchQueryAsMultiSourceResult<TParsed> method
MultiSourceResult<TParsed>
fetchQueryAsMultiSourceResult<TParsed>(
- String queryId,
- BaseOptions<
TParsed> options
Wrap both the eagerResult
and networkResult
future in a MultiSourceResult
if the cache policy precludes a network request, networkResult
will be null
Implementation
MultiSourceResult<TParsed> fetchQueryAsMultiSourceResult<TParsed>(
String queryId,
BaseOptions<TParsed> options,
) {
// create a new request to execute
final request = options.asRequest;
final QueryResult<TParsed> eagerResult = _resolveQueryEagerly(
request,
queryId,
options,
);
// _resolveQueryEagerly handles cacheOnly,
// so if we're loading + cacheFirst we continue to network
return MultiSourceResult(
options: options,
eagerResult: eagerResult,
networkResult:
(shouldStopAtCache(options.fetchPolicy) && !eagerResult.isLoading)
? null
: _resolveQueryOnNetwork(request, queryId, options),
);
}