标签:
var clickStream = new Rx.Observable(observer => { var handle = evt => observer.next(evt); element.addEventListener(‘click‘, handle); return () => element.removeEventListener(‘click‘, handle); }); subscription = clickStream.subscribe(evt => { console.log(‘onNext: ‘ + evt.id); }, err => { console.error(‘onError‘); }, () => { console.log(‘onComplete‘); }); setTimeout(() => { subscription.unsubscribe(); }, 1000);
标签:
原文地址:http://www.cnblogs.com/dojo-lzz/p/5875714.html