Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@heridux/core

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@heridux/core

The easiest way to use and reuse redux stores or react internal states

  • 0.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Table of Contents

Heridux

Creation of a Heridux store

Parameters

  • STATE_PROPERTY String string name for this slice of state. Generated actions wille use this as a prefix.

Examples

import Heridux from "@heridux/core"

const store = new Heridux("counterStore")

setInitialState

Define the initial state of the store slice

Parameters
Examples
import Heridux from "@heridux/core"

const store = new Heridux("counterStore")

store.setInitialState({ counter : 0 })

Returns undefined

createAction

Create action/reducer couple

Parameters
  • name String action short name
  • reducer Function function to modify the state
Examples
const myStore = new Heridux("myPartialStore")

myStore.setInitialState({
 list : ["foo", "bar"]
})

myStore.createAction("pop", state => state.slice(0, -1))

Returns undefined

execAction

  • **See: createAction **

Execute action registered by createAction method

Parameters
  • name String action short name
  • options Object additional parameters
Examples
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

getState

Get store slice

Parameters
  • _state Object? global state (if not specified, call getState method of redux store)
Examples
import Heridux from "@heridux/core"

const store = new Heridux("counterStore")

store.setInitialState({ counter : 0 })

store.register()

store.getState() // { counter : 0 }

Returns Object store slice

get

Shortcut to get js value of a first level key

Parameters
  • key String key name
  • _state Object? global state (if not specified, call getState method of redux store)
Examples
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

Register heridux store in global redux store

Examples
import Heridux from "@heridux/core"

const store = new Heridux("counterStore")

store.setInitialState({ counter : 0 })

store.createAction("increment", state => {
  state.counter++
})

store.register()

Returns undefined

createReduxStore

Create an empty redux store configured for Heridux. Add Redux DevTools if available

Examples
import Heridux from "@heridux/core"

export default Heridux.createReduxStore()

Returns Object redux store

connect

Connect Heridux to an existing redux store

Parameters
  • store Object existing redux store
  • initialReducers Function reducing function
Examples
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

Keywords

FAQs

Package last updated on 18 Feb 2021

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc