I'm using redux observable as a middleware for redux to deal with side effects. I want to dispatch action A only when action B was emitted more than twice in some specified period of time (say 500ms).
My attempt for this: demo
Here is how epic looks:
const pingEpic = action$ =>
action$
.buffer(action$.ofType(CLICK).throttleTime(500))
.map(x => x.length)
.filter(x => x >= 2)
.mapTo({ type: PING });
This epic correctly accumulates clicks in lists and filters those that are longer than 2, but the PING action is dispatched after another additional click.