Rx.Notification.prototype.accept([observer] | [onNext], [onError], [onCompleted])

Invokes the delegate corresponding to the notification or the observer's method corresponding to the notification and returns the produced result.

参数

  1. [observer] (Observer): Observer to invoke the notification on.
  2. [onNext] (Function): Function to invoke for an OnNext notification.
  3. [onError] (Function): Function to invoke for an OnError notification.
  4. [onError] (Function): Function to invoke for an OnCompleted notification.

返回值

(Any): Result produced by the observation.

Using an observer
var observer = Rx.Observer.create(x => x);

var notification = Rx.Notification.createOnNext(42);

console.log(notification.accept(observer));

// => 42
Using a function
var notification = Rx.Notification.createOnNext(42);

console.log(notification.accept(x => x));
// => 42