merge<R> function

Merges the items emitted by the given events into a single EventHandler.

Interactive marble diagram

Example

merge(
 [
   eventManager.on<EventA>().map((e) => e.value), // emits ['a']
   eventManager.on<EventB>().map((e) => e.value), // emits ['b']
   eventManager.on<EventC>().map((e) => e.value), // emits ['c']
 ],
).subscribeFunction(print); // prints 'a', 'b', 'c'

Implementation

EventSubscriptionBuilder<R> merge<R>(
  List<EventSubscriptionBuilder<R>> events,
) {
  if (events.isEmpty) {
    throw ArgumentError.value(
      events,
      'events',
      'Cannot be empty',
    );
  }

  final builder = _MergeEventSubscriptionBuilder<R>(
    events: events,
  );

  return builder;
}