{"_id":"@doodle3d/redux-batched-subscribe","_rev":"2-e09d31f3735ede654909e4879f3ec046","name":"@doodle3d/redux-batched-subscribe","description":"redux store enhancer which allows batching subscribe notifications.","dist-tags":{"latest":"0.1.7"},"versions":{"0.1.7":{"name":"@doodle3d/redux-batched-subscribe","version":"0.1.7","description":"redux store enhancer which allows batching subscribe notifications.","main":"lib/index.js","files":["lib","README.md"],"scripts":{"clean":"rimraf lib","build":"babel src --out-dir lib","lint":"eslint src","test":"mocha --compilers js:babel/register --recursive src/**/*-test.js","prepublish":"npm run clean && npm run lint && npm run test && npm run build"},"keywords":["redux","batched","react","reactjs","performance","store"],"author":{"name":"Terry Appleby","email":"terry.appleby@gmail.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/tappleby/redux-batched-subscribe.git"},"bugs":{"url":"https://github.com/tappleby/redux-batched-subscribe/issues"},"homepage":"https://github.com/tappleby/redux-batched-subscribe","devDependencies":{"babel":"^5.8.20","babel-core":"^5.8.20","eslint":"^1.0.0","eslint-config-airbnb":"2.1.1","expect":"^1.13.4","mocha":"^2.2.5","rimraf":"^2.5.0"},"gitHead":"4ba9ec29a94f52af3156f635d82d5630520cf164","_id":"@doodle3d/redux-batched-subscribe@0.1.7","_shasum":"aa75e9092eaea6bc8a6694250229a73fca166df1","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.11.1","_npmUser":{"name":"peteruithoven","email":"peter@peteruithoven.nl"},"dist":{"shasum":"aa75e9092eaea6bc8a6694250229a73fca166df1","tarball":"https://registry.npmjs.org/@doodle3d/redux-batched-subscribe/-/redux-batched-subscribe-0.1.7.tgz","integrity":"sha512-CkQ3gX1wXs3ce+gtwqv9HeFKneHXidqMNMtBXPdhqlqF+d/8ppedL34JJYFZJGfbk0gzw8XpXsvAVPJI3wv+AA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGEpbHdiYoAo+1+VZC1liDzNNWXt3z34jKkyImnT1ofvAiEA9+2ohaANB5blU2MfLkT4uNO7MEZidYo7AFGHOQiLu1A="}]},"maintainers":[{"name":"peteruithoven","email":"peter@peteruithoven.nl"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/redux-batched-subscribe-0.1.7.tgz_1499880430418_0.7132291498128325"}}},"readme":"redux-batched-subscribe\n=====================\n\n[![build status](https://img.shields.io/travis/tappleby/redux-batched-subscribe/master.svg?style=flat-square)](https://travis-ci.org/tappleby/redux-batched-subscribe)\n[![npm version](https://img.shields.io/npm/v/redux-batched-subscribe.svg?style=flat-square)](https://www.npmjs.com/package/redux-batched-subscribe)\n\nStore enhancer for [redux](https://github.com/rackt/redux) which allows batching of subscribe notifications that occur as a result of dispatches.\n\n```js\nnpm install --save redux-batched-subscribe\n```\n\n## Usage\n\nThe `batchedSubscribe` store enhancer accepts a function which is called after every dispatch with a `notify` callback as a single argument. Calling the `notify` callback will trigger all the subscription handlers, this gives you the ability to use various techniques to delay subscription notifications such as: debouncing, React batched updates or requestAnimationFrame.\n\nSince `batchedSubscribe` overloads the dispatch and subscribe handlers on the original redux store it is important that it gets applied before any other store enhancers or middleware that depend on these functions; The [compose](https://github.com/rackt/redux/blob/master/docs/api/compose.md) utility in redux can be used to handle this:\n\n```js\nimport { createStore, applyMiddleware, compose } from 'redux';\nimport { batchedSubscribe } from 'redux-batched-subscribe';\n\nconst enhancer = compose(\n  applyMiddleware(...middleware),\n  batchedSubscribe((notify) => {\n    notify();\n  })\n)\n\n// Note: passing enhancer as the last argument to createStore requires redux@>=3.1.0\nconst store = createStore(reducer, initialState, enhancer);\n```\n\n*Note: since `compose` applies functions from right to left, `batchedSubscribe` should appear at the end of the chain.*\n\nThe store enhancer also exposes a `subscribeImmediate` method which allows for unbatched subscribe notifications.\n\n## Examples\n\n### Debounced subscribe handlers:\n\n```js\nimport { createStore } from 'redux';\nimport { batchedSubscribe } from 'redux-batched-subscribe';\nimport debounce from 'lodash.debounce';\n\nconst debounceNotify = debounce(notify => notify());\n// Note: passing batchedSubscribe as the last argument to createStore requires redux@>=3.1.0\nconst store = createStore(reducer, intialState, batchedSubscribe(debounceNotify));\n```\n\n### React batched updates\n\n```js\nimport { createStore } from 'redux';\nimport { batchedSubscribe } from 'redux-batched-subscribe';\n\n// React <= 0.13\nimport { addons } from 'react/addons';\nconst batchedUpdates = addons.batchedUpdates;\n\n// React 0.14\nimport { unstable_batchedUpdates as batchedUpdates } from 'react-dom';\n\n// Note: passing batchedSubscribe as the last argument to createStore requires redux@>=3.1.0\nconst store = createStore(reducer, intialState, batchedSubscribe(batchedUpdates));\n```\n\n## Thanks\n\nThanks to [Andrew Clark](https://github.com/acdlite) for the clean library structure.\n","maintainers":[{"name":"cappieh","email":"casperlamboo@gmail.com"},{"name":"peteruithoven","email":"peter@peteruithoven.nl"}],"time":{"modified":"2022-06-12T17:14:11.358Z","created":"2017-07-12T17:27:11.467Z","0.1.7":"2017-07-12T17:27:11.467Z"},"homepage":"https://github.com/tappleby/redux-batched-subscribe","keywords":["redux","batched","react","reactjs","performance","store"],"repository":{"type":"git","url":"git+https://github.com/tappleby/redux-batched-subscribe.git"},"author":{"name":"Terry Appleby","email":"terry.appleby@gmail.com"},"bugs":{"url":"https://github.com/tappleby/redux-batched-subscribe/issues"},"license":"MIT","readmeFilename":"README.md"}