startWith method

ReactiveSubject<T> startWith(
  1. T startValue
)

Prepends a given value to the source ReactiveSubject.

Usage:

final subject = ReactiveSubject<int>(initialValue: 1);
final started = subject.startWith(0);
started.stream.listen(print); // Prints: 0, 1
subject.add(2); // Prints: 2

Implementation

ReactiveSubject<T> startWith(T startValue) {
  final result = ReactiveSubject<T>(initialValue: startValue);
  stream.startWith(startValue).listen(result.add, onError: result.addError);
  return result;
}