Exemple #1
0
  compute() {
    let { _parentValue, _propertyKey } = this;

    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);

      this._propertyTag.inner.update(tag);
    }

    return ret;
  }
Exemple #2
0
  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;
    }
  }