Skip to content

Home > @unseenco/backstage-dataverse > Atom

Atom class

Wraps an object whose (sub)properties can be individually tracked.

Signature:

typescript
export default class Atom<State> implements PointerToPrismProvider

Implements: PointerToPrismProvider

Constructors

ConstructorModifiersDescription
(constructor)(initialState)Constructs a new instance of the Atom class

Properties

PropertyModifiersTypeDescription
pointerreadonlyPointer<State>Convenience property that gives you a pointer to the root of the atom.
prismreadonlyPrism<State>

Methods

MethodModifiersDescription
get()
getByPointer(pointerOrFn)Returns the value at the given pointer
pointerToPrism(pointer)Returns a new prism of the value at the provided path.
reduce(fn)
reduceByPointer(pointerOrFn, reducer)Reduces the value at the given pointer
set(newState)Sets the state of the atom.
setByPointer(pointerOrFn, val)Sets the value at the given pointer