@sandstack/neuron v0.0.0-beta.0.86
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 Vanilla 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 vanilla under the hood. See Neuron React as an example.
Setup Store
Create a new Store
import { createStore } from "@sandstack/neuron";
export const Store = createStore();
Add initial state to Store
Store.add({
key: "name",
state: "Ash Ketchum",
});
Store.add({
key: "age",
state: 10,
});
Update state
Store.set("name", "Gary Oak"); //key, new state
Get state
Store.get("name"); //key
Listen for state changes
Store.onDispatch((dispatchItem) => {
if (dispatchItem.key === "name") {
console.log(dispatchItem.state);
}
});
//initial console.log output
//name: Ash Ketchum
//new console.log output
//name: Gary Oak
Learn more about Vanilla Neuron and Neuron React.
4 days ago
9 days ago
11 days ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
2 months ago
2 months ago
3 months ago
3 months ago
3 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago