import { observable } from 'mobx';
import { component, observer, reaction } from 'web-cell';
@component({ tagName: 'my-tag' })
@observer
export class MyTag extends HTMLElement {
@observable
accessor count = 0;
@reaction(({ count }) => count)
handleCountChange(newValue: number, oldValue: number) {
console.log(`Count changed from ${oldValue} to ${newValue}`);
}
render() {
return (
<button onClick={() => this.count++}>
Up count {this.count}
</button>
);
}
}
Method decorator of MobX
reaction()