untitled notebook

node v6.11.2
version: master
endpointsharetweet
class Observable { constructor(producer) { this.subscribe = producer } } class Subject extends Observable { constructor() { super(function (observer) { this.observers.push(observer); }); this.observers = []; } next(x) { this.observers.forEach((observer) => observer.next(x)); } complete() { this.observers.forEach((observer) => observer.complete()); } } const observer = { next: (v) => console.log(v), complete: () => console.log('complete'), } const subject$ = new Subject(); subject$.subscribe(observer); subject$.next('hoge'); subject$.next('fuga'); subject$.complete();
Loading…

no comments

    sign in to comment