merge<T> static method

ReactiveSubject<T> merge<T>(
  1. List<ReactiveSubject<T>> subjects
)

Merges multiple ReactiveSubjects into a single ReactiveSubject.

Usage:

final subject1 = ReactiveSubject<int>(initialValue: 1);
final subject2 = ReactiveSubject<int>(initialValue: 2);
final merged = ReactiveSubject.merge([subject1, subject2]);
merged.stream.listen(print); // Prints: 1, 2
subject1.add(3); // Prints: 3

Implementation

static ReactiveSubject<T> merge<T>(List<ReactiveSubject<T>> subjects) {
  final result = ReactiveSubject<T>();
  Rx.merge(subjects.map((s) => s.stream))
      .listen(result.add, onError: result.addError);
  return result;
}