ts-state
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

ts-state

ts-state is a simple State Management System written in TypeScript. It is intended to be used in places where there is a need for state management at a small level. For example, if there is a Node.JS project, if multiple modules share the same variable, instead of using the global, one might feel the need to use this library.

Installation

npm i --save ts-state

How to use?

import { setState, getState } from  'ts-state'

console.log(getState()) // Outputs -> {}

setState()
console.log(getState()) // Outputs -> {}

setState({a: 10, b: 'bbb'})
console.log(getState()) // Outputs -> { a: 10, b: 'bbb' }

setState({a: 101, c: function() { console.log('ccc') }})
console.log(getState()) // Outputs -> { a: 101, b: 'bbb', c: [Function: c] }

getState()['c']() // Outputs -> ccc

Package Sidebar

Install

npm i ts-state

Weekly Downloads

4

Version

1.0.2

License

MIT

Unpacked Size

4.65 kB

Total Files

7

Last publish

Collaborators

  • itssayantan