@yobta/stores
v0.3.2
Published
An experimental module created for an education purpose
Downloads
80
Readme
Yobta Stores
A collection of tiny, observable stores designed to move logic away from components and help write reactive applications. These stores are:
- Small in size.
- Tree-shakable for optimal performance.
- Zero dependencies, so you don't have to worry about other libraries affecting your code.
- ESM-only, meaning they are compatible with ECMAScript Modules.
- Typescript compatible.
Installation
To install Yobta Stores, use the following command:
npm i @yobta/stores
Documentation
The following sections provide documentation on different parts of Yobta Stores:
Stores
- Basic - A general observable store for implementing any custom logic you need.
- Machine - A simple observable state machine.
- Map - An observable Map object.
- Connectivity - Tracks the browser's connectivity state.
- Modal - Tracks the browser's connectivity state.
- Plain Object - An observable plain object.
- Stack - An observable stack object.
- Derived - Aggregates data from one or multiple stores.
Plugins
- About Plugins - Basic information about plugins and middleware.
- Broadcast Channel - Syncs state between browsing contexts.
- Lazy - Resets the store to its initial state when idle.
- Local Storage - Persists and replicates state.
- Session Storage - Persists the store in one browsing context.
- Validation - Protects state.
Adapters
- Using with React - A store hook for React.
- Hook Factory - Makes React hooks from stores.
Utilities
- Codec - Encodes/decodes objects to/from JSON.
- Compose - Composes many functions into one.
- Map Diff - Compares Map objects.
- Object Diff - Compares plain objects.
- Map Codec - Encodes/decodes Maps to/from JSON.
- Observable - Creates an observable object.
- PubSub - Creates PubSub objects.
- Readable Store — Creates a read-only version of the store.
- Set Codec - Encodes/decodes Sets to/from JSON.
- Store Effect Utility — Adds ready/idle callbacks.
- Transition Effect Utility — Add state transition callback.
Alternatives: Jotai Nanostores Recoil
Kudos:
Andrey Sitnik
— nanostores and the package boilerplate