abhishiv / atom

Simple atom structure inspired by clojure's atom. Mutations are JSON RFC 6902 patches.

Home Page:https://abhishiv.github.io/atom

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

@gratico/atom

@gratico/atom

Simple atom structure inspired by clojure's atom. Mutations are JSON RFC 6902 patches.

Install and use

To use run npm install -g @gratico/atom

import {defAtom, commitPatch, defCursor, deref, defWatchableCursor} from "@gratico/atom"

const atom = defAtom({user: {profile: {name: "John"}}})

React.useLayoutEffect(() => {
  const cursor = defWatchableCursor(atom, ["user", "profile"]);
  cursor.addWatch(id, handler);
  return () => {
    cursor.removeWatch(id);
  };
}, []);
export * from "./atom";

About

Simple atom structure inspired by clojure's atom. Mutations are JSON RFC 6902 patches.

https://abhishiv.github.io/atom


Languages

Language:TypeScript 55.1%Language:Makefile 26.3%Language:JavaScript 18.6%