init method
Implementation
Future<void> init(K? key) {
if (_disposed) {
return Future.value();
}
return _guard.protect(() async {
if (!isEmpty) {
return;
}
try {
final Page<T, C>? page = await Backoff.run(
() => provider.init(key, perPage),
_cancelToken,
);
Log.debug(
'init(key: $key)... \n'
'\tFetched ${page?.edges.length} items\n'
'\tstartCursor: ${page?.info.startCursor}\n'
'\tendCursor: ${page?.info.endCursor}\n'
'\thasPrevious: ${page?.info.hasPrevious}\n'
'\thasNext: ${page?.info.hasNext}',
'$runtimeType',
);
for (var e in page?.edges ?? []) {
items[onKey(e)] = e;
}
startCursor = page?.info.startCursor;
endCursor = page?.info.endCursor;
hasNext.value = page?.info.hasNext ?? hasNext.value;
hasPrevious.value = page?.info.hasPrevious ?? hasPrevious.value;
Log.debug('init(key: $key)... done', '$runtimeType');
} catch (e) {
if (e is! OperationCanceledException) {
rethrow;
}
}
});
}