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

1.0.0-alpha.3 • Public • Published

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

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.0-alpha.33latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.0-alpha.33
1.0.0-alpha.20
1.0.0-alpha.10
0.5.11
0.5.01
0.4.00
0.3.00
0.2.10
0.2.01
0.1.00
0.0.01

Package Sidebar

Install

npm i enso

Weekly Downloads

7

Version

1.0.0-alpha.3

License

MIT

Unpacked Size

3.79 kB

Total Files

5

Last publish

Collaborators

  • kossnocorp