subscribe method
Starts listening to the stream and emits appropriate states.
Emits AsyncLoading initially, then AsyncSuccess for each stream value or AsyncError for stream errors.
Implementation
@override
FutureOr<void> subscribe(void Function(AsyncState<T> state) emit) async {
final completer = Completer<void>();
_sub = _stream.listen(
(data) => emit(AsyncSuccess(data)),
onError: (e, st) => emit(AsyncError(e, st)),
onDone: completer.complete,
);
await completer.future;
}