untitled notebook

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);

no comments

    sign in to comment

    running