fetch method
Fetch data fromNetwork.
Implementation
Future<void> fetch() async {
if (isLocked) return;
_setLocked(true);
emit(state.copyWith(isLoading: true));
try {
await for (final event in fromNetwork()) {
_updateLastUpdated();
emit(Data(value: event));
toMemory?.call(event);
await toStorage?.call(event);
}
} catch (e, s) {
_updateLastUpdated();
onError(e, s);
} finally {
emit(state.copyWith(isLoading: false));
}
_setLocked(false);
}