run method
Executes the effect immediately with the supplied handler. Each effect
implementation defines how it schedules work, emits values, and registers
disposables.
Implementation
@override
Future<void> run(
EffectHandler<Value> handler,
) {
if (!handler.guard()) return Future.value();
final cancellable = fromSubscription(
stream.listen(
handler.emit,
cancelOnError: cancelOnError,
onError: handleError(handler),
),
cancelOnError: cancelOnError,
).then(
(_) {
if (onDone != null) {
handler.emit(onDone!());
}
handler.dispose(shouldCancel: false);
},
onError: handleError(handler),
);
handler.register(cancellable);
return cancellable.value;
}