本文整理汇总了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);
}
}