Introduction to Nestore
What is this?
Nestore is state-management solution that uses event emitters and listeners to read from, write to and listen to the store - a plain old javascript object - inside of the nestore object.
Much of the functionality and API is inspired, or haunted, by other similar state management solutions, like
valtio, jotai, redux and zustand - with valtio being the most similar. See the
full comparison for more details.
Why would you?
This project originally started as a simple key-value store that extended the base event emitter to trigger UI updates within a Node.js CLI tool and centralize state logic. It quickly grew into a research experiment into the inner-workings of common state management solutions
Should I use this?
The are many other state-management solutions that likely contain the features that will satisfy the requirements of any project - as well as being more mature, well-tested and backed by large communities of developers and users.
Check out the full comparison below to see if this is the right choice for your project.
API Comparisons
| Feature | Solution | Comparison | |
Mutability Mutable store with persistent references | Nestore | Mutable store that can be mutated directly with or without triggering side-effects | |
| Redux | Immutable store that is only updated via actions and reducers | ||
| Zustand | Immutable store updated via an in-store set method | ||
| Valtio | Similar to Zustand - except with a mutable store | ||
| Jotai | Immutable 'read-only' store using atomic 'pieces' | ||
Flux Pattern Unidirectional data flow (dispatcher, store, view) | Nestore | Two-way data binding - pass data into and out of the store with any of the provided methods (impure functions and unpredictable time travel) | |
| Redux | Predictable and fully repeatable with one-way data binding with pure dispatch functions (predictable time travel) | ||
| Zustand | *Possible with user-created actions / dispatchers / reducers | ||
| Valtio | |||
| Jotai | Uses proxy-state to observe changes without selecting or differencing | ||
Wildcard Access and mutate the store using a wildcard character | Nestore | Store and events take advantage of wildcard and nested wildcard path strings | |
| Redux | No built-in usage of wildcards | ||
| Zustand | No built-in usage of wildcards | ||
| Valtio | No built-in usage of wildcards | ||
| Jotai | Similar to Zustand - except with a mutable store | ||
Middleware / Adapters Intercept and modify data / actions / payloads | Nestore | (Adapters - access and mutate the store at any time and in any order (non-sequential) | |
| Redux | Provides a third-party extension point between dispatching an action, and the moment it reaches the reducer. | ||
| Zustand | Zustand is interoperable with middleware as wrapper functions | ||
| Valtio | No support for middleware or adapters | ||
| Jotai | No suport for adapters or middleware | ||
Events Listen to and emit events | Nestore | Nestore extends the Event Emitter class with eventemitter2 | |
| Redux | |||
| Zustand | Z | ||
| Valtio | |||
| Jotai | Uses proxy-state to observe changes without selecting or differencing | ||