MCPcopy Index your code
hub / github.com/NativeScript/NativeScript / setProperty

Method setProperty

packages/core/data/observable/index.ts:141–155  ·  view source on GitHub ↗

* Updates the specified property with the provided value and raises a property change event and a specific change event based on the property name.

(name: string, value: any)

Source from the content-addressed store, hash-verified

139 * Updates the specified property with the provided value and raises a property change event and a specific change event based on the property name.
140 */
141 public setProperty(name: string, value: any): void {
142 const oldValue = this[name];
143 if (this[name] === value) {
144 return;
145 }
146 this[name] = value;
147 this.notifyPropertyChange(name, value, oldValue);
148
149 const specificPropertyChangeEventName = name + 'Change';
150 if (this.hasListeners(specificPropertyChangeEventName)) {
151 const eventData = this._createPropertyChangeData(name, value, oldValue);
152 eventData.eventName = specificPropertyChangeEventName;
153 this.notify(eventData);
154 }
155 }
156
157 /**
158 * Adds a listener for the specified event name.

Callers 1

Calls 4

notifyPropertyChangeMethod · 0.95
hasListenersMethod · 0.95
notifyMethod · 0.95

Tested by

no test coverage detected