冷热模式

1.Hot & Cold Observables
(1)Cold Observables:在被订阅后开始产生数据,即这类observables序列仅在subscribe()被调用后才会推送数据;

let obs = Rx.Observable.create(observer => observer.next(Date.now()));
obs.subscribe(v => console.log('1st subscriber:' + v)); //1st subscriber: 1465990942935
obs.subscribe(v => console.log('2st subscriber:' + v)); //2nd subscriber: 1465990942936
//两次获得的数据不同,即observer.next(Date.now())被调用了两次;

(2)Hot Observables:在被订阅之前就已经开始生成数据;

你可能感兴趣的:(冷热模式)