Skip to main content

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

FeatureSolutionComparison

Mutability

Mutable store with persistent references
NestoreMutable store that can be mutated directly with or without triggering side-effects
ReduxImmutable store that is only updated via actions and reducers
ZustandImmutable store updated via an in-store set method
ValtioSimilar to Zustand - except with a mutable store
JotaiImmutable 'read-only' store using atomic 'pieces'

Flux Pattern

Unidirectional data flow (dispatcher, store, view)
NestoreTwo-way data binding - pass data into and out of the store with any of the provided methods (impure functions and unpredictable time travel)
ReduxPredictable and fully repeatable with one-way data binding with pure dispatch functions (predictable time travel)
Zustand*Possible with user-created actions / dispatchers / reducers
Valtio
JotaiUses proxy-state to observe changes without selecting or differencing

Wildcard

Access and mutate the store using a wildcard character
NestoreStore and events take advantage of wildcard and nested wildcard path strings
ReduxNo built-in usage of wildcards
ZustandNo built-in usage of wildcards
ValtioNo built-in usage of wildcards
JotaiSimilar 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)
ReduxProvides a third-party extension point between dispatching an action, and the moment it reaches the reducer.
ZustandZustand is interoperable with middleware as wrapper functions
ValtioNo support for middleware or adapters
JotaiNo suport for adapters or middleware

Events

Listen to and emit events
NestoreNestore extends the Event Emitter class with eventemitter2
Redux
ZustandZ
Valtio
JotaiUses proxy-state to observe changes without selecting or differencing