// Create an observableconst myObs = Observable.create(observer => {
let x = 0;
const y = setInterval(() => {
// that emits incrementing values
observer.next(x++);
}, 1000); // each secondreturnfunctioncleanup() {
// and cleans up after its self
clearInterval(y);
}
});
Create an operator pipeline that operates on this observable
import { map, filter } from 'micr-observable'; myObs.pipe( map(x => x * x), // square each member filter(x => x % 3 === 0) // keep only multiples of 3 ).subscribe(x => { console.log(x); });;