我想做的是http://jsfiddle.net/staltz/4gGgs/27/,但要使用打字稿。
我已经达到以下目标:
const clickStream = fromEvent(document.getElementById('btnAction'), 'click');
const multiClickStream = clickStream.pipe(
buffer(clickStream.pipe(throttle(ev => interval(250)))),
map(list => list.length),
filter(x => x >= 2)
);
const singleClickStream = clickStream.pipe(
buffer(clickStream.pipe(throttle(ev => interval(250)))),
map(list => list.length),
filter(x => x === 1)
);
multiClickStream.subscribe(numClicks =>
document.querySelector('h2').textContent = `${numClicks}x click`
);
singleClickStream.subscribe(numClicks =>
document.querySelector('h2').textContent = `${numClicks}x click`
);
merge(singleClickStream, multiClickStream).pipe(
throttle(ev => interval(1000))
);
//document.querySelector('h2').textContent = '';
我没有得到相同的结果
感谢您的帮助