enso
Minimalistic TypeScript-first state managment library for Node.js and browser
Last updated 7 months ago by kossnocorp .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install enso 
SYNC missed versions from official npm registry.

Enso

Minimalistic TypeScript-first state managment library for Node.js and browser.

It's just 120 bytes, but it can be used to manage state in complex applications.

TypeScript-first approach ensures complete type-safety.

Simplistic API allows to get the state managment out of the way and write code.

import createState from 'enso'

// Define state
type State = number

// Create typed operations on state
const { get, set, start } = createState<State>()

// Update state every second
setInterval(() => set(counter => counter + 1), 1000)

// Listen to state changes. The passed function is also trigger with the initial state .
const initialCounter = 0
start(initialCounter, (newCounter, prevCounter) =>
  console.log(newCounter, prevCounter)
)
//=> 0 undefined
//=> 1 0
//=> 2 1
//=> ...

// Get the current state
setTimeout(() => console.log(get()), 3000)
//=> 3

License

MIT © Sasha Koss

Current Tags

  • 1.0.0-alpha.3                                ...           latest (7 months ago)

11 Versions

  • 1.0.0-alpha.3                                ...           7 months ago
  • 1.0.0-alpha.2                                ...           9 months ago
  • 1.0.0-alpha.1                                ...           9 months ago
  • 0.5.1                                ...           2 years ago
  • 0.5.0                                ...           2 years ago
  • 0.4.0                                ...           4 years ago
  • 0.3.0                                ...           5 years ago
  • 0.2.1                                ...           5 years ago
  • 0.2.0                                ...           5 years ago
  • 0.1.0                                ...           5 years ago
  • 0.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 2
Dependencies (0)
None
Dev Dependencies (13)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |