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