Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@sandstack/neuron

hjrdave141MIT0.0.0-beta.0.101TypeScript support: included

Neuron is a lightweight framework agnostic global state manager for Javascript apps, with React support

npm, module, node, javascript, typescript, global-state-management, state-manager, global, neuron, neuronjs, @sandstack, @neuron, sandstack, neuron-core

readme

npm version build npm bundle size

Neuron Global State Manager

The Neuron Global State Manager is a small, bare bones, framework agnostic library for building framework specific global state managers.

Neuron Core can be used in any js application by itself or you can tailor it to your framework of choice. My goal is to create framework specific version of this that use core under the hood. See React Neuron as an example.

Warning: This library is still experimental and is not ready for production.

Setup Neuron State

Create a new Neuron

import { Neuron } from "@sandstack/neuron";

const trainer = new Neuron("Ash Ketchum");

Update state

trainer.set("Gary Oak");

Get state

const name = trainer.getRef();

Listen for state changes

trainer.effect((payload) => {
  console.log(payload.state);
});

//initial console.log output
//name: Ash Ketchum

//new console.log output
//name: Gary Oak

Learn more about Neuron Core and React Neuron.