Skip to content

strange-life/jotai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jotai

A jotai clone for vanilla JS, made for fun and for my own use.

import { createStore, atom } from "@madahapa/jotai";

const store = createStore();
const countAtom = atom(0);
const doubleCountAtom = atom(
  (get) => get(countAtom) * 2,
  (get, set, value: number) => set(countAtom, value / 2)
);

const unsubscribe = store.subscribe(doubleCountAtom, function () {
  console.log(store.get(doubleCountAtom));
});

store.set(countAtom, (prev) => prev + 1);
unsubscribe();

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published