# y-state

> state manager (data manager)

Latest version **1.0.0** (published 2018-03-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install y-state
pnpm add y-state
yarn add y-state
bun add y-state
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2018-03-05 |
| First published | 2018-03-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 12 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Yuchen Liu |
| Maintainers | liuyuchenzh |
| Keywords | y-state |

## Links

- npm: https://www.npmjs.com/package/y-state
- Repository: https://github.com/liuyuchenzh/y-state
- Homepage: https://github.com/liuyuchenzh/y-state#readme
- Issues: https://github.com/liuyuchenzh/y-state/issues
- npm.io page: https://npm.io/package/y-state

## Recent versions

- 1.0.0 (latest) — 2018-03-05

## README

# y-state

## Intro

Simple implementation of state manager (data manager).

## Install

```bash
npm i y-state

# or

yarn add y-state
```

## Usage

```js
import State from 'y-state'
const option = {
  list: [
    {
      name: 'a',
      value: 1,
      watch(oldValue, newValue) {
        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

---
_Source: https://npm.io/package/y-state · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
