ns-observable-set-semantics
Installation
SKILL.md
Observable.set, fromObject, and listener identity
Three quiet rules in Observable cause most "my binding didn't update" bugs.
1. set() is a reference-equality no-op
Setting the same object instance fires nothing — mutating an array/object in place and setting it back updates no binding:
import { fromObject, WrappedValue } from '@nativescript/core';
const vm = fromObject({ items: [] as number[] });
const arr = vm.get('items');
arr.push(2);
vm.set('items', arr); // NO propertyChange — same reference
vm.set('items', WrappedValue.wrap(arr)); // fires propertyChange
WrappedValue exists only to force the change logic: the stored/observed value is the unwrapped array — vm.get('items') returns arr, not the wrapper. (Alternatives: store a new array (vm.set('items', [...arr])), or use ObservableArray — see ns-observable-array-change-events.)