Observable

Observable

Creates a new Observable

Constructor

new Observable(observerCallback)

Source:
Examples
const obs$ = new Observable((observer) => {
  for (let i = 0; i < 10; ++i) {
    observer.next(i);
  }

  observer.complete();
});
const obs$ = Observable.create((observer) => {
  for (let i = 0; i < 10; ++i) {
    observer.next(i);
  }

  observer.complete();
});
Parameters:
Name Type Description
observerCallback function

Classes

Observable

Methods

(static) create(observerCallback) → {Observable}

Source:
Parameters:
Name Type Description
observerCallback function
Returns:
Type
Observable

subscribe(nextopt, erroropt, completeopt) → {Subscription}

Source:
Example
observable$.subscribe(
 (value) => console.log('logs if next', value),
 () => console.log('logs if error'),
 () => console.log('logs if complete')
);
Parameters:
Name Type Attributes Description
next function <optional>
error function <optional>
complete function <optional>
Returns:
Type
Subscription