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.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by200%
Maintainers
1
Weekly downloads
 
Created
Source

Table of Contents

Heridux

Creation of Heridux store

Parameters

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

set

Set a first level value without creating a specific action

Parameters
  • prop String property name
  • value any property value

Returns undefined

getState

Get store slice

Parameters
  • state Immutable.Map? global state (if not specified, call getState method of redux store)

Returns Immutable.Map store slice

get

Get js value of a first level key

Parameters
  • key String key name
  • state Immutable.Map? global state (if not specified, call getState method of redux store)

Returns any key value (converted in plain js if immutable)

getIn

Get js value of a nested key

Parameters
  • path Array Iterable key path (more details in Immutable.js documentation)
  • state Immutable.Map? global state (if not specified, call getState method of redux store)
Examples
const store = new Heridux("myPartialStore")
store.setInitialState({
 list : [{ name : "foo"}, { name : "bar" }]
})
store.getIn(["list", 0, "name"]) // foo

Returns any key value (converted in plain js if immutable)

setInitialState

Define the initial state of the store slice. It will automatically be converted to immutable.

Parameters

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.update("list", arr => arr.pop())

myStore.execAction("pop")

myStore.get("list") //  ["foo"]

Returns undefined

execAction

  • **See: createAction **

Execute action registered by createAction method

Parameters
  • name String action short name
  • options Object additional parameters

Returns undefined

register

Register heridux store in global redux store

Returns undefined

dispatch

dispatch any action on global redux store

Parameters

Returns (undefined | Promise) promise if async

Keywords

FAQs

Package last updated on 23 Jan 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