Skip to content

liuyuchenzh/y-state

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

y-state

Intro

Simple implementation of state manager (data manager).

Install

npm i y-state

# or

yarn add y-state

Usage

import State from 'y-state'
const option = {
  list: [
    {
      name: 'a',
      value: 1,
      watch(newValue, oldValue) {
        console.log('old', oldValue, 'new', newValue)
      }
    }
  ]
}
const state = new State(option)
// assign directly
state.a = 2 // old 1 new 2
// assign with setState method
state.setState('a', 3) // old 2 new 3
state.setState({ a: 4 }) // old 3 new 4
state.setState('a', oldValue => oldValue + 1) // old 4 new 5

Support

IE >= 9, Node.js >= 4

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published