@observable
July 21, 2020 ยท View on GitHub
Decorator that can be used on ES7- or TypeScript class properties to make them observable.
The @observable can be used on instance fields and property getters.
This offers fine-grained control on which parts of your object become observable.
import { observable, computed } from "mobx"
class OrderLine {
@observable price = 0
@observable amount = 1
@computed get total() {
return this.price * this.amount
}
}
If your environment doesn't support decorators or field initializers,
use decorate instead (see decorators for details).