Open davidjbradshaw opened 6 years ago
@davidjbradshaw Thank you for your example it was extremely useful to me. Maybe it makes sense to post somewhere(for example on wiki) and refer it in REAME, what do you think?
I'm happy if @tappleby would like to do that.
Following on from the examples of @staab and @peteruithoven. Here is an example that selectively batches actions using
requestAnimationFrame
, based on the presence ofmeta.batch
in an action. It uses a middleware to inspect actions and callnotify()
.This allows the batching, for example async actions, whilst letting everything else work as normal.
You can replace
rafUpdateBatcher()
with LoDash'sdebounce()
if you prefer.batching/state.js
batching/enhancer.js
batching/rafUpdateBatcher.js
batching/middleware.js
store.js
Example action