Observing property changes with @observable
Learn how to work with Aurelia's observable decorator to create reactive properties inside your component view models that have change callbacks.
import { observable } from 'aurelia';
export class Car {
@observable color = 'blue';
colorChanged(newValue, oldValue) {
// this will fire whenever the 'color' property changes
}
}import { observable } from 'aurelia';
@observable('color')
@observable({ name: 'speed', callback: 'speedCallback' })
export class Car {
color = 'blue';
speed = 300;
colorChanged(newValue, oldValue) {
// this will fire whenever the 'color' property changes
}
speedCallback(newValue, oldValue) {
// this will fire whenever the 'speed' property changes
}
}Specifying a different change callback
Last updated
Was this helpful?