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

1.0.1 • Public • Published

Atome

Functional atoms and cursors

Atome is a functional set of helpers for creating and manipulating actoms and cursor written in TypeScript. It runs in the browser, or on the server using node.js.

Setup

yarn add atome

or

npm install --save atome

Usage

Before you start import the library

import { create, cursor, deref, reset, watch } from 'atome'

Basic usage

// Setup a new atom
const atom = create({ topic: { base: true } })
const pointer = cursor(atom, ['topic'])
 
// Update the data
const context = { test: true }
 
// Setup a watcher
const unwatch = watch(atom, () => {
  console.log(deref(atom), deref(pointer)) // { topic: { test: true } } { base: true }
})
 
// Reset the cursor data
reset(pointer, context)
 
// Cleanup
unwatch()

License

MIT

Package Sidebar

Install

npm i atome

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

43 kB

Total Files

14

Last publish

Collaborators

  • claudiuandrei