docs: clarify per-handler event transformer semantics (#3248) - #4819
docs: clarify per-handler event transformer semantics (#3248)#4819champ96k wants to merge 1 commit into
Conversation
Each registered event handler operates on its own independent stream pipeline. Different handlers with different transformers do not affect each other's execution. - Add 'Per-Handler Event Transformers' section to bloc-concepts.mdx - Clarify doc comments in all bloc_concurrency transformers - Clarify that 'no event handler overlap' refers to the specific handler using the transformer, not other handlers on the same Bloc Part of felangel#3248
|
Thanks for tackling #3248, @champ96k — the per-handler scoping is exactly the right thing to clarify. Sharing a few suggestions that I think would strengthen the PR, cc @felangel for a maintainer steer: 1. Use a snippet component instead of a raw code fence. Every code sample in 2. Make the example self-consistent. The current sample references 3. Answer the follow-up the reporter actually asked. In #3248, class SearchBloc extends Bloc<SearchEvent, SearchState> {
SearchBloc() : super(const SearchState.initial()) {
// A single handler on the shared supertype sequences every subtype.
on<SearchEvent>(_onEvent, transformer: sequential());
}
Future<void> _onEvent(SearchEvent event, Emitter<SearchState> emit) async {
switch (event) {
case QueryChanged():
// ...
case SearchCleared():
// ...
}
}
}4. Worth a one-liner on the invariant. On the transformer doc comments: the clarifications read well. Minor: the appended paragraph is the same three lines verbatim across all four transformers — folding the scope note into each existing Happy to open a PR against your branch with these if that's easier, or you're welcome to lift any of it directly — whatever you and @felangel prefer. Thanks again for pushing this forward. 🙏 |
Status
READY
Breaking Changes
NO
Description
Each registered event handler operates on its own independent stream pipeline. Different handlers with different transformers do not affect each other's execution.
Changes
Per-Handler Event Transformerssection tobloc-concepts.mdxexplaining eachon<E>()call creates an independent subscription that filters the shared event stream by type and applies its own transformer, with a Dart example showing two handlers with different transformers on the same Bloc.bloc_concurrencytransformers (sequential,restartable,droppable,concurrent) that their guarantees apply per-handler, not across handlers.Related Issues
Part of #3248
Type of Change