Simple State
Internal package
Deep proxies an object so it is only updateable through an update callback.
outside an updater, it is impossible to make changes
It only proxies simple objects (not maps or sets) and arrays
It doesnt create new references and doesnt copy over anything
Original object is changed!
Installation
#Yarn:
$ yarn add @rpldy/simple-state
#NPM:
$ npm i @rpldy/simple-state
Example
import createState from "@rpldy/simple-state"
const { state, update } = createState({
arr: [1,2,3]
});
state.arr.push(4);
console.log(state.arr);
update((state) => {
state.arr.push(4);
});
console.log(state.arr);