Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
action-creator
Advanced tools
A simple way to write function with context dependencies without context parameter
A simple way to write function with context dependencies without context parameter
npm install action-creator
# or
yarn add action-creator
import {bindActionCreators, connect} from 'action-creator'
Param actionCreators
is a object contain action creators
, like:
bindActionCreators({
getIp: () => {},
getUserName: () => {},
})
it will return a function, and then pass param ctx
to this function. like:
const ctx = {
req: {},
res: {}
}
bindActionCreators({
getIp: () => {},
getUserName: () => {},
})(ctx)
it will return a object contains {getIp, getUserName}
, now you can use getIp
directly.
An action is written like (..args) => (ctx, getAction) => {...}
, so if you want to use getAction
method,
you must connect
it with other actions you need. like:
const getName = (...args) => (ctx, getAction) => {
const {getParentName} = getAction()
return getParentName(...args) + args[1]
}
// ... after do bindActionCreators(...)(ctx), you run getName() will
// cause an Error 'getParentName is not a function'
const connectedGetName = connect(
bindActionCreators({
getParentName
})
)(getName)
// this will be ok
MIT
FAQs
A simple way to write function with context dependencies without context parameter
The npm package action-creator receives a total of 2 weekly downloads. As such, action-creator popularity was classified as not popular.
We found that action-creator 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.