RxJS
create observable
// create
const stream$ = Observable.create((observer) => {
observer.next(1);
observer.error('error message');
observer.complete();
return function () {
someCleanUp();
};
});
// producer
class Producer {
i = 0;
nextValue() {
return this.i++;
}
}
// range
let stream$ = range(1, 3);
// from
let stream$ = from(/* Array, Promise */);
// of
let stream$ = of(1, 2, 3, 4);