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

Method constructor

packages/core/ui/core/properties/index.ts:178–340  ·  view source on GitHub ↗
(options: PropertyOptions<T, U>)

Source from the content-addressed store, hash-verified

176 public configurable = true;
177
178 constructor(options: PropertyOptions<T, U>) {
179 const propertyName = options.name;
180 this.name = propertyName;
181
182 const key = Symbol(propertyName + ':propertyKey');
183 this.key = key;
184
185 const getDefault = Symbol(propertyName + ':getDefault');
186 this.getDefault = getDefault;
187
188 const setNative = Symbol(propertyName + ':setNative');
189 this.setNative = setNative;
190
191 const defaultValueKey = Symbol(propertyName + ':nativeDefaultValue');
192 this.defaultValueKey = defaultValueKey;
193
194 const defaultValue: U = options.defaultValue;
195 this.defaultValue = defaultValue;
196
197 const eventName = propertyName + 'Change';
198
199 let equalityComparer = options.equalityComparer;
200 let affectsLayout: boolean = options.affectsLayout;
201 let valueChanged = options.valueChanged;
202 let valueConverter = options.valueConverter;
203 let overrideConverter = false;
204
205 this.overrideHandlers = function (options: PropertyOptions<T, U>) {
206 if (typeof options.equalityComparer !== 'undefined') {
207 equalityComparer = options.equalityComparer;
208 }
209 if (typeof options.affectsLayout !== 'undefined') {
210 affectsLayout = options.affectsLayout;
211 }
212 if (typeof options.valueChanged !== 'undefined') {
213 valueChanged = options.valueChanged;
214 }
215 if (typeof options.valueConverter !== 'undefined') {
216 valueConverter = options.valueConverter;
217 overrideConverter = true;
218 }
219 };
220
221 const property = this;
222
223 this.set = function (this: T, boxedValue: U): void {
224 const reset = isResetValue(boxedValue);
225 let value: U;
226 let wrapped: boolean;
227 if (reset) {
228 value = defaultValue;
229 } else {
230 wrapped = boxedValue && (<any>boxedValue).wrapped;
231 value = wrapped ? WrappedValue.unwrap(boxedValue) : boxedValue;
232
233 if (valueConverter && typeof value === 'string') {
234 value = overrideConverter ? valueConverter.call(this, value) : valueConverter(value);
235 }

Callers

nothing calls this directly

Calls 10

isResetValueFunction · 0.90
unwrapMethod · 0.80
hasListenersMethod · 0.65
notifyMethod · 0.65
attributeRemovedMethod · 0.65
attributeModifiedMethod · 0.65
valueConverterFunction · 0.50
valueChangedFunction · 0.50
callMethod · 0.45
requestLayoutMethod · 0.45

Tested by

no test coverage detected