0.1.5 • Published 9 months ago

vanilla-cafe v0.1.5

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago
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()
0.1.5

9 months ago

0.1.4

9 months ago

0.1.3

10 months ago

0.1.2

10 months ago

0.1.1

10 months ago

0.1.0

10 months ago

0.0.0

10 months ago