mobx-method-decorators
v0.0.7
Published
![Node.js CI](https://github.com/mk2/mobx-method-decorators/workflows/Node.js%20CI/badge.svg?branch=master)
Downloads
6
Readme
mobx-method-decorators
- Assist
reaction(...)
calling with class-oriented way.
How to use?
isntall
yarn add mobx-method-decorators
write code
import mobx from 'mobx';
import { ReactableMixin, reactionMethod } from 'mobx-method-decorators';
const store = mobx.observable({
message: 'Hello world.',
});
class Sample extends ReactableMixin {
constructor() {
this.makeReactable();
}
@reactionMethod(() => store.message)
method() {
// Execute whenever store.message changed.
}
detach() {
// Dispose any reactions, call `unmakeReactable`
this.unmakeReactable();
}
}
Copyright
MIT