本文整理匯總了TypeScript中@ember/-internals/metal.watchKey函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript watchKey函數的具體用法?TypeScript watchKey怎麽用?TypeScript watchKey使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了watchKey函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: compute
compute() {
let { _parentReference, _parentObjectTag, _propertyKey } = this;
let parentValue = _parentReference.value();
_parentObjectTag.inner.update(tagForProperty(parentValue, _propertyKey));
let parentValueType = typeof parentValue;
if (parentValueType === 'string' && _propertyKey === 'length') {
return parentValue.length;
}
if ((parentValueType === 'object' && parentValue !== null) || parentValueType === 'function') {
if (DEBUG) {
watchKey(parentValue, _propertyKey);
}
if (DEBUG) {
(this.tag.inner as TwoWayFlushDetectionTag).didCompute(parentValue);
}
return get(parentValue, _propertyKey);
} else {
return undefined;
}
}
示例2: compute
compute() {
let { _parentReference, _propertyTag, _propertyKey } = this;
let parentValue = _parentReference.value();
let parentValueType = typeof parentValue;
if (parentValueType === 'string' && _propertyKey === 'length') {
return parentValue.length;
}
if ((parentValueType === 'object' && parentValue !== null) || parentValueType === 'function') {
if (DEBUG) {
watchKey(parentValue, _propertyKey);
}
if (DEBUG) {
(this.tag.inner as TwoWayFlushDetectionTag).didCompute(parentValue);
}
let parent: any;
let tracker: any;
if (EMBER_METAL_TRACKED_PROPERTIES) {
parent = getCurrentTracker();
tracker = setCurrentTracker();
}
let ret = get(parentValue, _propertyKey);
if (EMBER_METAL_TRACKED_PROPERTIES) {
setCurrentTracker(parent!);
let tag = tracker!.combine();
if (parent) parent.add(tag);
_propertyTag.inner.update(tag);
} else {
_propertyTag.inner.update(tagForProperty(parentValue, _propertyKey));
}
return ret;
} else {
return undefined;
}
}
示例3: constructor
constructor(parentValue: any, propertyKey: string) {
super();
this._parentValue = parentValue;
this._propertyKey = propertyKey;
if (DEBUG) {
this.tag = TwoWayFlushDetectionTag.create(
tagForProperty(parentValue, propertyKey),
propertyKey,
this
);
} else {
this.tag = tagForProperty(parentValue, propertyKey);
}
if (DEBUG) {
watchKey(parentValue, propertyKey);
}
}
示例4: constructor
constructor(parentValue: any, propertyKey: string) {
super();
this._parentValue = parentValue;
this._propertyKey = propertyKey;
if (EMBER_METAL_TRACKED_PROPERTIES) {
this._propertyTag = UpdatableTag.create(CONSTANT_TAG);
} else {
this._propertyTag = UpdatableTag.create(tagForProperty(parentValue, propertyKey));
}
if (DEBUG) {
this.tag = TwoWayFlushDetectionTag.create(this._propertyTag, propertyKey, this);
} else {
this.tag = this._propertyTag;
}
if (DEBUG) {
watchKey(parentValue, propertyKey);
}
}