toNotifier

Creates a notification callback from an observer.

Returns

(Function): The function that forwards its input notification to the underlying observer.

var observer = Rx.Observer.create(
  x => console.log(`onNext: ${x}`),
  e => console.log(`onError: ${e}`),
  () => console.log('onCompleted'));

var notifier = observer.toNotifier();

// Invoke with onNext
notifier(Rx.Notification.createOnNext(42));
// => onNext: 42

// Invoke with onCompleted
notifier(Rx.Notification.createOnCompleted());
// => onCompleted

Example

Last updated