Gathering detailed insights and metrics for redux-batched-subscribe
Gathering detailed insights and metrics for redux-batched-subscribe
Gathering detailed insights and metrics for redux-batched-subscribe
Gathering detailed insights and metrics for redux-batched-subscribe
npm install redux-batched-subscribe
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
504 Stars
25 Commits
32 Forks
8 Watching
3 Branches
2 Contributors
Updated on 12 Aug 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-39.1%
4,394
Compared to previous day
Last week
-13.9%
27,048
Compared to previous week
Last month
12.1%
128,217
Compared to previous month
Last year
-37.1%
1,888,268
Compared to previous year
7
Store enhancer for redux which allows batching of subscribe notifications that occur as a result of dispatches.
1npm install --save redux-batched-subscribe
The 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.
Since 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 utility in redux can be used to handle this:
1import { createStore, applyMiddleware, compose } from 'redux'; 2import { batchedSubscribe } from 'redux-batched-subscribe'; 3 4const enhancer = compose( 5 applyMiddleware(...middleware), 6 batchedSubscribe((notify) => { 7 notify(); 8 }) 9) 10 11// Note: passing enhancer as the last argument to createStore requires redux@>=3.1.0 12const store = createStore(reducer, initialState, enhancer);
Note: since compose
applies functions from right to left, batchedSubscribe
should appear at the end of the chain.
The store enhancer also exposes a subscribeImmediate
method which allows for unbatched subscribe notifications.
1import { createStore } from 'redux'; 2import { batchedSubscribe } from 'redux-batched-subscribe'; 3import debounce from 'lodash.debounce'; 4 5const debounceNotify = debounce(notify => notify()); 6// Note: passing batchedSubscribe as the last argument to createStore requires redux@>=3.1.0 7const store = createStore(reducer, intialState, batchedSubscribe(debounceNotify));
1import { createStore } from 'redux'; 2import { batchedSubscribe } from 'redux-batched-subscribe'; 3 4// React >= 0.14 5import { unstable_batchedUpdates } from 'react-dom'; 6 7// Note: passing batchedSubscribe as the last argument to createStore requires redux@>=3.1.0 8const store = createStore(reducer, intialState, batchedSubscribe(unstable_batchedUpdates));
Thanks to Andrew Clark for the clean library structure.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 1/25 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More