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

0.1.5 • Public • Published
npm i vanilla-cafe

Create a store

import { createStore } from "vanilla-cafe";

export const { set, sub, get } = createStore({
  count: 0
})

Update states

import { set, sub, get } from '../store';

function increment(){
  set.count(p => p + 1)
}

Subscribe to changes

let count = 0;

function handleCountChange(newValue){
  count = newValue
}

const unsubscribe = sub.count(handleCountChange)

Get the current state's value

const count = get.count()

Package Sidebar

Install

npm i vanilla-cafe

Weekly Downloads

2

Version

0.1.5

License

MIT

Unpacked Size

3.9 kB

Total Files

6

Last publish

Collaborators

  • glitch-txs