@zedux/atoms
TypeScript icon, indicating that this package has built-in type declarations

1.2.3 • Public • Published

@zedux/atoms

The core atomic model of Zedux. This is a standalone package, meaning it's the only package you need to install to use Zedux's atomic model. It includes the Zedux core store package as well as all APIs related to atoms and ecosystems.

This package is framework-independent, though many of its APIs are heavily inspired by React.

If you're new to Zedux, you're probably looking for the quick start.

Installation

npm install @zedux/atoms # npm
yarn add @zedux/atoms # yarn
pnpm add @zedux/atoms # pnpm

If you're using React, you probably want to install the @zedux/react package instead, which includes everything from this package and more.

This package has a direct dependency on the @zedux/core package. If you install that directly, ensure its version exactly matches your @zedux/atoms version to prevent installing duplicate packages.

Usage

See the top-level README for a general overview of Zedux.

See the Zedux documentation for comprehensive usage details.

Basic example:

import { atom, createEcosystem } from '@zedux/atoms'

const greetingAtom = atom('greeting', 'Hello, World!')
const ecosystem = createEcosystem({ id: 'root' })

const instance = ecosystem.getInstance(greetingAtom)

instance.store.subscribe(newState => console.log('state updated:', newState))
instance.setState('Goodbye, World!')
instance.destroy()

Exports

This package includes and re-exports everything from the following package:

On top of this, @zedux/atoms exports the following APIs and many helper types for working with them in TypeScript:

Classes

Factories

Injectors

Utils

For Authors

If your lib only uses APIs in this package, it's recommended to only import this package, not @zedux/react. It's recommended to use a peer dependency + dev dependency on this package.

Contributing, License, Etc

See the top-level README for all the technical stuff.

Package Sidebar

Install

npm i @zedux/atoms

Weekly Downloads

2,346

Version

1.2.3

License

MIT

Unpacked Size

1.11 MB

Total Files

227

Last publish

Collaborators

  • bowheart