zip<R> function
EventSubscriptionBuilder<R>
zip<R>(
- List<
EventSubscriptionBuilder> events, - R zipper(
- List events
Zips the items emitted by the given events
into a single
EventHandler using the zipper
function.
Consider using the typed version zip2 - zip9.
Example
zip(
[
eventManager.on<EventA>(), // emits ['a']
eventManager.on<EventB>(), // emits ['b', 'B']
eventManager.on<EventC>(), // emits ['c', 'C']
],
(values) => values.join(' '),
).subscribeFunction(print); // prints 'a b c'
Implementation
EventSubscriptionBuilder<R> zip<R>(
List<EventSubscriptionBuilder<dynamic>> events,
R Function(List<dynamic> events) zipper,
) {
if (events.isEmpty) {
throw ArgumentError.value(
events,
'events',
'Cannot be empty',
);
}
final builder = _ZipEventSubscriptionBuilder<R>(
zipper: zipper,
events: events,
);
return builder;
}