@zedux/stores v2.0.0-beta.0
@zedux/stores
The composable store model of Zedux. This is an addon package with a dependency on @zedux/atoms
and @zedux/core
. It includes (via re-exporting) the Zedux core store package as well as all APIs related to working with stores in atoms.
This package is framework-independent and can run in any JS runtime. It's considered a "legacy" package of Zedux, since Zedux's main packages have switched to a signals-based model
If you're new to Zedux, you're probably looking for the quick start. You may also want to avoid this package, preferring the newer signal-based APIs in the @zedux/react
or @zedux/atoms
packages.
Installation
npm install @zedux/stores # npm
yarn add @zedux/stores # yarn
pnpm add @zedux/stores # pnpm
If you're using React, you probably want to install the @zedux/react
package alongside this package (and very likely want to skip this package altogether. Prefer signals).
This package has a direct dependency on both the @zedux/core
package and @zedux/atoms
package. If you install those directly, ensure their versions exactly match your @zedux/stores
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/stores'
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/stores
exports the following APIs and many helper types for working with them in TypeScript. Note that most of these have newer, signals-based versions in the @zedux/react
(or @zedux/atoms
) package that you should prefer.
Classes
Factories
Injectors
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.
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
5 months ago
5 months ago
5 months ago
6 months ago
6 months ago