minbx
v0.3.0
Published
mini mobx
Downloads
2,303
Maintainers
Readme
minbx
mini mobx: main part of mobx, for new learners who diving into the source code
Usage
same as using mobx
install:
yarn add minbx
import
import { observable, computed, autorun, set, get, has, $mobx } from 'minbx';
import { observer, Observer, useObserver } from 'minbx'; // react
- example
- normal
class Store {
@observable obj = { a: 1 };
@observable arr = [2, 3];
@observable str = 'hello';
@observable bool = true;
@observable num = 4;
@computed get mixed() {
return store.str + '/' + store.num;
}
}
const store = new Store();
autorun(r => {
console.log('auto', store.str, store.obj.a, store.dbl);
});
store.str = 'change';
- react
const A = observer(() => <div>observable: {store.num}</div>);
const B = <Observer>{() => <div>Inner Component</div>}</Observer>
Blog Posts
don't forget to ❤️