untitled notebook

node v6.12.2
version: master
endpointsharetweet
class Observable { constructor(producer) { this.subscribe = producer } } Observable.prototype.of = function (...values) { const producer = observer => { values.forEach(v => observer.next(v)); observer.complete(); } return new Observable(producer) } const observer = { next: (v) => console.log(v), complete: () => console.log('complete'), } new Observable().of(1,2,3).subscribe(observer);
Loading…

no comments

    sign in to comment