Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
@doodle3d/redux-batched-subscribe
Advanced tools
redux store enhancer which allows batching subscribe notifications.
Store enhancer for redux which allows batching of subscribe notifications that occur as a result of dispatches.
npm 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:
import { createStore, applyMiddleware, compose } from 'redux';
import { batchedSubscribe } from 'redux-batched-subscribe';
const enhancer = compose(
applyMiddleware(...middleware),
batchedSubscribe((notify) => {
notify();
})
)
// Note: passing enhancer as the last argument to createStore requires redux@>=3.1.0
const 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.
import { createStore } from 'redux';
import { batchedSubscribe } from 'redux-batched-subscribe';
import debounce from 'lodash.debounce';
const debounceNotify = debounce(notify => notify());
// Note: passing batchedSubscribe as the last argument to createStore requires redux@>=3.1.0
const store = createStore(reducer, intialState, batchedSubscribe(debounceNotify));
import { createStore } from 'redux';
import { batchedSubscribe } from 'redux-batched-subscribe';
// React <= 0.13
import { addons } from 'react/addons';
const batchedUpdates = addons.batchedUpdates;
// React 0.14
import { unstable_batchedUpdates as batchedUpdates } from 'react-dom';
// Note: passing batchedSubscribe as the last argument to createStore requires redux@>=3.1.0
const store = createStore(reducer, intialState, batchedSubscribe(batchedUpdates));
Thanks to Andrew Clark for the clean library structure.
FAQs
redux store enhancer which allows batching subscribe notifications.
The npm package @doodle3d/redux-batched-subscribe receives a total of 0 weekly downloads. As such, @doodle3d/redux-batched-subscribe popularity was classified as not popular.
We found that @doodle3d/redux-batched-subscribe demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.