Declarative lifecycle hooks invoked automatically during slot mutation.
When an auto-generated slot setter runs (e.g. setName("Thorin")), it checks for optional convention-based hook methods on the owning object before and after mutating internal state:
(class Character extends SvStorableNode {
initPrototypeSlots () {
{
const slot = this.newSlot("level", 1);
slot.setSlotType("Number");
slot.setSyncsToView(true);
}
}
// Optional hook called BEFORE value is mutated
willUpdateSlotLevel (oldValue, newValue) {
console.log("Level changing from", oldValue, "to", newValue);
}
// Optional hook called AFTER value is mutated
didUpdateSlotLevel (oldValue, newValue) {
this.recalculateHitPoints();
}
}.initThisClass());setName(newValue)willUpdateSlotName(oldVal, newVal): Called if defined on the object._name is updated.didUpdateSlotName(oldVal, newVal): Called if defined on the object.setSyncsToView(true) is set, posts "didChangeSlot" notification via SvNotificationCenter.