{"id":13437677,"url":"https://github.com/tappleby/redux-batched-subscribe","last_synced_at":"2025-05-16T14:04:57.874Z","repository":{"id":35848080,"uuid":"40131971","full_name":"tappleby/redux-batched-subscribe","owner":"tappleby","description":"store enhancer for https://github.com/reactjs/redux which allows batching subscribe notifications.","archived":false,"fork":false,"pushed_at":"2018-07-15T05:44:43.000Z","size":21,"stargazers_count":503,"open_issues_count":11,"forks_count":32,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-05-16T14:04:56.571Z","etag":null,"topics":["batching","performance","redux","store-enhancer"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tappleby.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-03T15:20:46.000Z","updated_at":"2025-03-24T15:40:11.000Z","dependencies_parsed_at":"2022-07-10T19:32:19.281Z","dependency_job_id":null,"html_url":"https://github.com/tappleby/redux-batched-subscribe","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tappleby%2Fredux-batched-subscribe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tappleby%2Fredux-batched-subscribe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tappleby%2Fredux-batched-subscribe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tappleby%2Fredux-batched-subscribe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tappleby","download_url":"https://codeload.github.com/tappleby/redux-batched-subscribe/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254544146,"owners_count":22088807,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["batching","performance","redux","store-enhancer"],"created_at":"2024-07-31T03:00:59.240Z","updated_at":"2025-05-16T14:04:57.852Z","avatar_url":"https://github.com/tappleby.png","language":"JavaScript","funding_links":[],"categories":["Uncategorized","Code Design","Marks","📦 Legacy \u0026 Inactive Projects"],"sub_categories":["Uncategorized","Data Store","[React - A JavaScript library for building user interfaces](http://facebook.github.io/react)"],"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) =\u003e {\n    notify();\n  })\n)\n\n// Note: passing enhancer as the last argument to createStore requires redux@\u003e=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 =\u003e notify());\n// Note: passing batchedSubscribe as the last argument to createStore requires redux@\u003e=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 \u003e= 0.14\nimport { unstable_batchedUpdates } from 'react-dom';\n\n// Note: passing batchedSubscribe as the last argument to createStore requires redux@\u003e=3.1.0\nconst store = createStore(reducer, intialState, batchedSubscribe(unstable_batchedUpdates));\n```\n\n## Thanks\n\nThanks to [Andrew Clark](https://github.com/acdlite) for the clean library structure.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftappleby%2Fredux-batched-subscribe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftappleby%2Fredux-batched-subscribe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftappleby%2Fredux-batched-subscribe/lists"}