当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript ember-meta.peekMeta函数代码示例

本文整理汇总了TypeScript中ember-meta.peekMeta函数的典型用法代码示例。如果您正苦于以下问题:TypeScript peekMeta函数的具体用法?TypeScript peekMeta怎么用?TypeScript peekMeta使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了peekMeta函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: key

/**
  This function is called just after an object property has changed.
  It will notify any observers and clear caches among other things.

  Normally you will not need to call this method directly but if for some
  reason you can't directly watch a property you can invoke this method
  manually.

  @method notifyPropertyChange
  @for Ember
  @param {Object} obj The object with the property that will change
  @param {String} keyName The property key (or path) that will change.
  @param {Meta} meta The objects meta.
  @return {void}
  @private
*/
function notifyPropertyChange(obj: object, keyName: string, _meta?: Meta): void {
  let meta = _meta === undefined ? peekMeta(obj) : _meta;
  let hasMeta = meta !== undefined;

  if (hasMeta && !meta.isInitialized(obj)) {
    return;
  }

  let possibleDesc = descriptorFor(obj, keyName, meta);

  if (possibleDesc !== undefined && typeof possibleDesc.didChange === 'function') {
    possibleDesc.didChange(obj, keyName);
  }

  if (hasMeta && meta.peekWatching(keyName) > 0) {
    dependentKeysDidChange(obj, keyName, meta);
    chainsDidChange(obj, keyName, meta);
    notifyObservers(obj, keyName, meta);
  }

  if (PROPERTY_DID_CHANGE in obj) {
    obj[PROPERTY_DID_CHANGE](keyName);
  }

  if (hasMeta) {
    if (meta.isSourceDestroying()) {
      return;
    }
    markObjectAsDirty(obj, keyName, meta);
  }

  if (DEBUG) {
    assertNotRendered(obj, keyName);
  }
}
开发者ID:chundabear,项目名称:ember.js,代码行数:51,代码来源:property_events.ts

示例2: hasListeners

export function hasListeners(obj: object, eventName: string) {
  let meta = peekMeta(obj);
  if (meta === undefined) {
    return false;
  }
  let matched = meta.matchingListeners(eventName);
  return matched !== undefined && matched.length > 0;
}
开发者ID:Artmann,项目名称:ember.js,代码行数:8,代码来源:events.ts

示例3: arrayContentDidChange

export function arrayContentDidChange(
  array: { length: number },
  startIdx: number,
  removeAmt: number,
  addAmt: number
) {
  // if no args are passed assume everything changes
  if (startIdx === undefined) {
    startIdx = 0;
    removeAmt = addAmt = -1;
  } else {
    if (removeAmt === undefined) {
      removeAmt = -1;
    }

    if (addAmt === undefined) {
      addAmt = -1;
    }
  }

  let meta = peekMeta(array);

  if (addAmt < 0 || removeAmt < 0 || addAmt - removeAmt !== 0) {
    notifyPropertyChange(array, 'length', meta);
  }

  notifyPropertyChange(array, '[]', meta);

  eachProxyArrayDidChange(array, startIdx, removeAmt, addAmt);

  sendEvent(array, '@array:change', [array, startIdx, removeAmt, addAmt]);

  let cache = peekCacheFor(array);
  if (cache !== undefined) {
    let length = array.length;
    let addedAmount = addAmt === -1 ? 0 : addAmt;
    let removedAmount = removeAmt === -1 ? 0 : removeAmt;
    let delta = addedAmount - removedAmount;
    let previousLength = length - delta;

    let normalStartIdx = startIdx < 0 ? previousLength + startIdx : startIdx;
    if (cache.has('firstObject') && normalStartIdx === 0) {
      notifyPropertyChange(array, 'firstObject', meta);
    }

    if (cache.has('lastObject')) {
      let previousLastIndex = previousLength - 1;
      let lastAffectedIndex = normalStartIdx + removedAmount;
      if (previousLastIndex < lastAffectedIndex) {
        notifyPropertyChange(array, 'lastObject', meta);
      }
    }
  }

  return array;
}
开发者ID:Artmann,项目名称:ember.js,代码行数:56,代码来源:array_events.ts

示例4: SETTER_FUNCTION

 function SETTER_FUNCTION(this: object, value: any | undefined | null) {
   let m = peekMeta(this);
   if (!m.isInitialized(this)) {
     m.writeValues(name, value);
   } else {
     assert(
       `You must use set() to set the \`${name}\` property (of ${this}) to \`${value}\`.`,
       false
     );
   }
 }
开发者ID:chundabear,项目名称:ember.js,代码行数:11,代码来源:properties.ts

示例5: detect

 /**
   @method detect
   @param obj
   @return {Boolean}
   @private
 */
 detect(obj: any): boolean {
   if (typeof obj !== 'object' || obj === null) {
     return false;
   }
   if (obj instanceof Mixin) {
     return _detect(obj, this);
   }
   let meta = peekMeta(obj);
   if (meta === undefined) {
     return false;
   }
   return meta.hasMixin(this);
 }
开发者ID:realityendshere,项目名称:ember.js,代码行数:19,代码来源:mixin.ts

示例6: IGETTER_FUNCTION

  function IGETTER_FUNCTION(this: any) {
    let meta = peekMeta(this);
    let val;
    if (meta !== undefined) {
      val = meta.readInheritedValue('values', name);
    }

    if (val === UNDEFINED) {
      let proto = Object.getPrototypeOf(this);
      return proto && proto[name];
    } else {
      return val;
    }
  }
开发者ID:chundabear,项目名称:ember.js,代码行数:14,代码来源:properties.ts

示例7: unwatchPath

export function unwatchPath(obj: any, keyPath: string, meta?: Meta): void {
  let m = meta === undefined ? peekMeta(obj) : meta;
  if (m === undefined) {
    return;
  }
  let counter = m.peekWatching(keyPath);

  if (counter > 0) {
    m.writeWatching(keyPath, counter - 1);
    if (counter === 1) {
      m.writableChains(makeChainNode).remove(keyPath);
    }
  }
}
开发者ID:Artmann,项目名称:ember.js,代码行数:14,代码来源:watch_path.ts

示例8: arrayDidChange

 arrayDidChange(content: T[] | EmberArray<T>, idx: number, _removedCnt: number, addedCnt: number) {
   let keys = this._keys;
   if (!keys) {
     return;
   }
   let lim = addedCnt > 0 ? idx + addedCnt : -1;
   let meta = peekMeta(this);
   for (let key in keys) {
     if (lim > 0) {
       addObserverForContentKey(content, key, this, idx, lim);
     }
     notifyPropertyChange(this, key, meta);
   }
 }
开发者ID:Artmann,项目名称:ember.js,代码行数:14,代码来源:each_proxy.ts

示例9: mixins

  // returns the mixins currently applied to the specified object
  // TODO: Make `mixin`
  static mixins(obj: object): Mixin[] {
    let meta = peekMeta(obj);
    let ret: Mixin[] = [];
    if (meta === undefined) {
      return ret;
    }

    meta.forEachMixins((currentMixin: Mixin) => {
      // skip primitive mixins since these are always anonymous
      if (!currentMixin.properties) {
        ret.push(currentMixin);
      }
    });

    return ret;
  }
开发者ID:realityendshere,项目名称:ember.js,代码行数:18,代码来源:mixin.ts

示例10: didChange

  // invalidate cache when CP key changes
  didChange(obj: object, keyName: string) {
    // _suspended is set via a CP.set to ensure we don't clear
    // the cached value set by the setter
    if (this._volatile || this._suspended === obj) {
      return;
    }

    // don't create objects just to invalidate
    let meta = peekMeta(obj);
    if (meta === undefined || meta.source !== obj) {
      return;
    }

    let cache = peekCacheFor(obj);
    if (cache !== undefined && cache.delete(keyName)) {
      removeDependentKeys(this, obj, keyName, meta);
    }
  }
开发者ID:chundabear,项目名称:ember.js,代码行数:19,代码来源:computed.ts


注:本文中的ember-meta.peekMeta函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。