You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
At first, thanks for this awesome package, this is really useful for our project.
My feature request is about handling asynchronous events. In my case I have an event which calls a usecase very often and it takes some time before this event was handled.
If I close this bloc, the asynchronous calls are still running which leads to issues.
Desired Solution
So I wanted to ask if it's possible to call something to close all current running events, e.g. cancelRunningEvents();.
Or the default behavior could be that it just cancels automatically all running events after closing the bloc.
Another idea would be to add some configuration to the bloc or to a specific event which tells it to stop the event after closing the bloc.
Additional Context
This is an example code which illustrates my issue:
classTestBlocextendsBloc<TestEvent, TestState> {
TestBloc() :super(TestInitial()) {
on<TestRunEvent>(this._onTestRunEvent);
}
@overrideFuture<void> close() async {
cancelAllRunningEvents(); // I would wish to something like thisawaitsuper.close();
}
Future<void> _onTestRunEvent(
TestRunEvent event,
Emitter<TestState> emit,
) async {
for (int i =0; i <10; i++) {
if(isClosed) return; // I would like to prevent doing these checksprint('Running with counter = $i');
// currently this call is still running even though my bloc was closedawaitFuture.delayed(constDuration(seconds:2));
}
}
}
The text was updated successfully, but these errors were encountered:
Description
At first, thanks for this awesome package, this is really useful for our project.
My feature request is about handling asynchronous events. In my case I have an event which calls a usecase very often and it takes some time before this event was handled.
If I close this bloc, the asynchronous calls are still running which leads to issues.
Desired Solution
So I wanted to ask if it's possible to call something to close all current running events, e.g.
cancelRunningEvents();
.Or the default behavior could be that it just cancels automatically all running events after closing the bloc.
Another idea would be to add some configuration to the bloc or to a specific event which tells it to stop the event after closing the bloc.
Additional Context
This is an example code which illustrates my issue:
The text was updated successfully, but these errors were encountered: