On this page
article
Merge
MergeExtension combines multiple functions into a single function whose result aggregates the results of all sources.
Merge
What it is
MergeExtension combines multiple functions into a single function whose result aggregates the results of all sources.
When to use it
- Running several independent queries and combining their results.
- Parallel fan-out where you need all outputs.
- Composing multiple validators or enrichers.
API reference
| |
Parameters
| Parameter | Type | Description |
|---|---|---|
sources | List<Func1<T, dynamic>> | Functions to execute in parallel. |
combiner | R Function(List<dynamic>) | Combines all source results into a single result. |
Examples
Basic example
| |
Real-world example
| |
Best practices
- Keep targets independent;
Mergeruns them concurrently. - Make the merger handle result ordering deterministically.
- Combine with
catchErroron individual targets if partial failure is acceptable.
Common pitfalls
- One failure fails all: If any target throws, the merge throws. Wrap targets individually if you need resilience.
- Merger assumptions: The merger receives results in the same order as
targets.