New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@converge/state

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@converge/state

Minimal state management library similar to `redux`, with `immer` built in.

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
Maintainers
1
Weekly downloads
 
Created
Source

@converge/state · Version License JavaScript Standard Style

Minimal state management library similar to redux, with immer built in.

installation

# using yarn:
yarn add @converge/state

# or npm:
npm i @converge/state

usage

import { createStore } from "@converge/state"

const store = createStore({ count: 0 }, {
  plus: (by = 1) => state => { state.count += by },
  minus: (by = 1) => state => { state.count -= by },
  reset: () => () => ({ count: 0 })
})

const { plus, minus, reset } = store.getActions()

const unsubscribe = store.subscribe(() => {
  console.log(store.getState())
})

plus()
// -> { count: 1 }

plus(2)
// -> { count: 3 }

minus(2)
// -> { count: 1 }

reset()
// -> { count: 0 }

unsubscribe()

const { state, actions } = store.useStore()

console.log(state)
// -> { count: 0 }

actions.plus(10)

console.log(state)
// -> { count: 0 }

console.log(store.getState())
// -> { count: 10 }

see also

  • redux – predictable state container for JS apps
  • immer – create the next immutable state by mutating the current one

contributing

Search the issues if you come across any trouble, open a new one if it hasn't been posted, or, if you're able, open a pull request. Contributions of any kind are welcome in this project.

license

MIT © Bo Lingen / citycide

Keywords

FAQs

Package last updated on 03 Jul 2020

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