Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
35 lines (28 sloc) 805 Bytes

Lets you create your own Observable. How cool is that? 😎
While enjoying this might, don't forget that now you have greater responsibility.

const { rxObserver } = require('api/v0.3');
const { Observable } = require('rxjs');
const { take } = require('rxjs/operators');


const source$ = new Observable(observer => {
  let index = 0;
  const id = setInterval(()=>{
    observer.next(index++);
  }, 10);

  // return a teardown function
  return ()=>{
    clearInterval(id);
  };
});

source$.pipe(
    take(5)
  )
  .subscribe(rxObserver());
You can’t perform that action at this time.