felangel / felangel/bloc

feat: An eventHandlerTransformer to control how multiple event handlers emit their values

Open
#2,802 4 comments 2 reactions 1 assignee Claimed by @felangel View on GitHub
enhancement candidate
Dominant language
Dart
Stars
12.5k
Forks
3.4k
PR merge metrics
No merged PRs in 30d

Description

**Description**

Hello, I ported my blocs to the new `on()` API and things mostly worked :) However I was also affected by the issue raised in #2790 since my blocs expect event handling to be done sequentially. Setting all handlers to sequential() wasn't enough because handling *between multiple event handlers* is always done concurrently (right?)

The suggested solution to use a single `on()` handler with a sequential transformer worked, but it does take away from the elegance of the new API imo

**Proposal**

It would be cool if the event handling order could also be configured. Perhaps an `eventHandlerTransformer` (that gets passed into the constructor?) which lets you configure whether two or more event handlers are run concurrently, sequentially, etc.

So for example, a `Reload` event handler could be droppable, so multiple `Reload` events added in quick succession will only process the first one and drop the succeeding ones. But on a bloc level, inter-event handling could be sequential, so multiple `Reload` events followed by an `Upvote` event in quick succession will result in one reload that finishes (others dropped), followed by the handling of the upvote event after the reload.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.