0.3.0 • Published 3 years ago

minbx v0.3.0

Weekly downloads
21
License
ISC
Repository
github
Last release
3 years ago

minbx

mini mobx: main part of mobx, for new learners who diving into the source code

Usage

same as using mobx

  1. install: yarn add minbx

  2. import

import { observable, computed, autorun, set, get, has, $mobx } from 'minbx';

import { observer, Observer, useObserver } from 'minbx'; // react
  1. 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 ❤️

0.3.0

3 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.2

4 years ago

0.1.0

4 years ago

0.1.1

4 years ago

0.0.1

4 years ago