Сan I use the Mobx library to call a class method when data changes?
For example MyObject
writes container['item'] = 10
and as a result the myaction
method is called.
class MyElement extends Component<any> {
// modifiable data
container: any = [];
// method called when data (container) is modified
myaction() {
console.log('container was modified');
console.log(this.container);
}
render() {
<MyObject container = {this.container} />
}
}
decorate(MyElement, {
container: observable
} as any)