mobx-box
Discussion here.
const store = new class {- @observable foo = '';- @observable bar = '';- - @action setFoo = value => (this.foo = value);- @action setBar = value => (this.bar = value);+ @box foo = '';+ @box bar = '';}(); console.log(store.foo); // ''console.log(store.bar); // '' - store.setFoo('Lorem');- store.setBar('Ipsum');+ // these are mobx actions (internally), not direct mutations, they don't violate strict mode+ store.foo = 'Lorem';+ store.bar = 'Ipsum'; console.log(store.foo); // 'Lorem'console.log(store.bar); // 'Ipsum'
Install
yarn add mobx mobx-box
Example
; ;; ; ; const store = @box foo = 0; // or without decorators { ; }; const Example = <div> <button onClick= storefoo = Date>storefoo</button> <button onClick= storebar = Date>storebar</button> </div>; Example;