July 2018
Beginner
236 pages
5h 34m
English
If you are not interested in any changes happening inside a data structure (object, array, map) and only in the change in value, @observable.ref is what you are looking for. It will only monitor reference changes to the observable.
import { observable, action } from 'mobx';class FormData { @observable.ref validations = null; @observable username = ''; @observable password = ''; @action validate() { const { username, password } = this; this.validations = applyValidations({ username, password }); }}
In the preceding example, the validations observable is always assigned a new value. Since we are never modifying the properties of this object, it is better to mark it as @observable.ref ...
Read now
Unlock full access