This package has been deprecated

Author message:

kefir-atom -> kefir.atom

kefir-atom

1.1.2 • Public • Published

npm version

Modifiable models for Kefir.

Note: This implementation is optimized for space at a fairly low level. The good news is that you can use atoms and lenses with impunity. The bad news is that the implementation is tightly bound to the internals of Kefir. Should the internals change, this library will need to be updated as well.

Reference

import Atom from "kefir-atom"

Atom(initialValue)

Creates a new atom with the given initial value. An atom is a modifiable Kefir property. Atoms (and lensed atoms) implicitly skip duplicates using Ramda's equals function.

atom.get()

A slow operation to synchronously get the current value of the atom. Use of get is discouraged: prefer to depend on an atom as you would with ordinary Kefir properties.

atom.lens(l, ...ls)

Creates a new lensed atom with the given path from the original atom. Modifications to the lensed atom are reflected in the original atom and vice versa.

The lens can be any Ramda compatible lens, but the lenses on the given path are implicitly composed and lifted as partial lenses.

atom.modify(currentValue => newValue)

Applies the given function to the current value of the atom and replaces the value of the atom with the new value returned by the function.

atom.set(value)

atom.set(value) is equivalent to atom.modify(() => value) and is provided for convenience.

atom.view(l, ...ls)

Creates a new view with the given path from the original atom. Changes to the original atom are reflected in the view.

Package Sidebar

Install

npm i kefir-atom

Weekly Downloads

0

Version

1.1.2

License

MIT

Last publish

Collaborators

  • polytypic