Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
@heridux/core
Advanced tools
The easiest way to use and reuse redux stores or react internal states
Creation of a Heridux store
STATE_PROPERTY
String string name for this slice of state. Generated actions wille use this as a prefix.import Heridux from "@heridux/core"
const store = new Heridux("counterStore")
Define the initial state of the store slice
state
Object plain js stateimport Heridux from "@heridux/core"
const store = new Heridux("counterStore")
store.setInitialState({ counter : 0 })
Returns undefined
Create action/reducer couple
const myStore = new Heridux("myPartialStore")
myStore.setInitialState({
list : ["foo", "bar"]
})
myStore.createAction("pop", state => state.slice(0, -1))
Returns undefined
Execute action registered by createAction method
const myStore = new Heridux("myPartialStore")
myStore.setInitialState({
list : ["foo", "bar"]
})
myStore.createAction("pop", state => state.slice(0, -1))
myStore.register()
myStore.execAction("pop")
myStore.get("list") // ["foo"]
Returns undefined
Get store slice
_state
Object? global state (if not specified, call getState method of redux store)import Heridux from "@heridux/core"
const store = new Heridux("counterStore")
store.setInitialState({ counter : 0 })
store.register()
store.getState() // { counter : 0 }
Returns Object store slice
Shortcut to get js value of a first level key
key
String key name_state
Object? global state (if not specified, call getState method of redux store)import Heridux from "@heridux/core"
const store = new Heridux("counterStore")
store.setInitialState({ counter : 0 })
store.register()
store.get("counter") === store.getState().counter // true
Returns any key value
Register heridux store in global redux store
import Heridux from "@heridux/core"
const store = new Heridux("counterStore")
store.setInitialState({ counter : 0 })
store.createAction("increment", state => {
state.counter++
})
store.register()
Returns undefined
Create an empty redux store configured for Heridux. Add Redux DevTools if available
import Heridux from "@heridux/core"
export default Heridux.createReduxStore()
Returns Object redux store
Connect Heridux to an existing redux store
import { createStore } from "redux"
import Heridux from "@heridux/core"
const reducers = function(state){ return state }
const store = createStore(reducers)
Heridux.connect(store, reducers)
export default store
Returns undefined
FAQs
The easiest way to use and reuse redux stores or react internal states
We found that @heridux/core 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
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.