I have two events, execution of PrepareEpubBook event lasts 10-15 sec. During this execution, I call from UI CancelBookPreparing event, but this event executes only after PrepareEpubBook event finishes.
if (event is CancelBookPreparing) {
_cancelToken.cancel();
yield BookOpeningCancel();
} else if (event is PrepareEpubBook) {
...
await _downloadBook(event.bookData.downloadURL, bookPath);
...
How can I cancel execution of PrepareEpubBook event and make CancelBookPreparing event? Or How can I run CancelBookPreparing event during PrepareEpubBook event?
Hi @RomanSoviak 馃憢
You could override transformEvents and use switchMap instead of the default asyncExpand. This will drop the previous event when a new event is entering bloc.
@RollyPeres thanks!
Most helpful comment
Hi @RomanSoviak 馃憢
You could override
transformEventsand useswitchMapinstead of the defaultasyncExpand. This will drop the previous event when a new event is entering bloc.