cold<T> method

Observable<T> cold<T>(
  1. String marbles, {
  2. Map<String, T> values = const {},
  3. Object error = 'Error',
})

Creates a "cold" Observable whose events replay each time it is being subscribed to.

Implementation

Observable<T> cold<T>(String marbles,
    {Map<String, T> values = const {}, Object error = 'Error'}) {
  final sequence =
      TestEventSequence<T>.fromString(marbles, values: values, error: error);
  if (sequence.events.whereType<SubscribeEvent<T>>().isNotEmpty) {
    throw ArgumentError.value(marbles, 'marbles',
        'Cold observable cannot have subscription marker.');
  }
  if (sequence.events.whereType<UnsubscribeEvent<T>>().isNotEmpty) {
    throw ArgumentError.value(marbles, 'marbles',
        'Cold observable cannot have un-subscription marker.');
  }
  final observable = ColdObservable<T>(this, sequence);
  observables.add(observable);
  return observable;
}