toObservable

Returns an observable sequence with a single notification.

Arguments

  1. [scheduler = Rx.Scheduler.immediate] (Scheduler): Scheduler to send out the notification calls on.

Returns

(Observable): The observable sequence that surfaces the behavior of the notification upon subscription.

Example

var source = Rx.Notification.createOnNext(42)
    .toObservable();

var subscription = source.subscribe(
  x => console.log(`onNext: ${x}`),
  e => console.log(`onError: ${e}`),
  () => console.log('onCompleted'));

// => onNext: 42
// => onCompleted

var source = Rx.Notification.createOnError(new Error('error!'))
    .toObservable(Rx.Scheduler.timeout);

var subscription = source.subscribe(
  x => console.log(`onNext: ${x}`),
  e => console.log(`onError: ${e}`),
  () => console.log('onCompleted'));

// => onError: Error: error!

Without a scheduler

With a scheduler

Last updated