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


TypeScript meta.meta函数代码示例

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


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

示例1: get

 get(obj: object, keyName: string) {
   let ret = get(obj, this.altKey);
   let cache = getCacheFor(obj);
   if (cache.get(keyName) !== CONSUMED) {
     let meta = metaFor(obj);
     cache.set(keyName, CONSUMED);
     addDependentKeys(this, obj, keyName, meta);
   }
   return ret;
 }
开发者ID:rlivsey,项目名称:ember.js,代码行数:10,代码来源:alias.ts

示例2: watchPath

export function watchPath(obj: any, keyPath: string, meta?: Meta): void {
  let m = meta === undefined ? metaFor(obj) : meta;
  let counter = m.peekWatching(keyPath);

  m.writeWatching(keyPath, counter + 1);
  if (counter === 0) {
    // activate watching first time
    m.writableChains(makeChainNode).add(keyPath);
  }
}
开发者ID:GreatWizard,项目名称:ember.js,代码行数:10,代码来源:watch_path.ts

示例3: tagFor

export function tagFor(object: any | null, _meta?: Meta): Tag {
  if (typeof object === 'object' && object !== null) {
    let meta = _meta === undefined ? metaFor(object) : _meta;

    if (!meta.isMetaDestroyed()) {
      return meta.writableTag(makeTag);
    }
  }

  return CONSTANT_TAG;
}
开发者ID:emberjs,项目名称:ember.js,代码行数:11,代码来源:tags.ts

示例4: applyMixin

export function applyMixin(obj: { [key: string]: any }, mixins: Mixin[]) {
  let descs = {};
  let values = {};
  let meta = metaFor(obj);
  let keys: string[] = [];
  let key, value, desc;

  (obj as any)._super = ROOT;

  // Go through all mixins and hashes passed in, and:
  //
  // * Handle concatenated properties
  // * Handle merged properties
  // * Set up _super wrapping if necessary
  // * Set up computed property descriptors
  // * Copying `toString` in broken browsers
  mergeMixins(mixins, meta, descs, values, obj, keys);

  for (let i = 0; i < keys.length; i++) {
    key = keys[i];
    if (key === 'constructor' || !values.hasOwnProperty(key)) {
      continue;
    }

    desc = descs[key];
    value = values[key];

    if (ALIAS_METHOD) {
      while (value && value instanceof AliasImpl) {
        let followed = followMethodAlias(obj, value, descs, values);
        desc = followed.desc;
        value = followed.value;
      }
    }

    if (desc === undefined && value === undefined) {
      continue;
    }

    if (descriptorForProperty(obj, key) !== undefined) {
      replaceObserversAndListeners(obj, key, null, value);
    } else {
      replaceObserversAndListeners(obj, key, obj[key], value);
    }

    defineProperty(obj, key, desc, value, meta);
  }

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

示例5: removeListener

export function removeListener(
  obj: object,
  eventName: string,
  target: object | null,
  method?: Function | string
) {
  assert('You must pass at least an object and event name to removeListener', !!obj && !!eventName);

  if (!method && 'function' === typeof target) {
    method = target;
    target = null;
  }

  metaFor(obj).removeFromListeners(eventName, target, method!);
}
开发者ID:knownasilya,项目名称:ember.js,代码行数:15,代码来源:events.ts

示例6: addListener

export function addListener(
  obj: object,
  eventName: string,
  target: object | Function | null,
  method?: Function | string,
  once?: boolean
) {
  assert('You must pass at least an object and event name to addListener', !!obj && !!eventName);

  if (!method && 'function' === typeof target) {
    method = target;
    target = null;
  }

  metaFor(obj).addToListeners(eventName, target, method!, once === true);
}
开发者ID:GreatWizard,项目名称:ember.js,代码行数:16,代码来源:events.ts

示例7: removeListener

export function removeListener(
  obj: object,
  eventName: string,
  target: object | null,
  method?: Function | string
): void {
  assert('You must pass at least an object and event name to removeListener', !!obj && !!eventName);

  if (!method && 'function' === typeof target) {
    method = target;
    target = null;
  }

  let m = metaFor(obj);

  if (method === undefined) {
    m.removeAllListeners(eventName);
  } else {
    m.removeFromListeners(eventName, target, method);
  }
}
开发者ID:Turbo87,项目名称:ember.js,代码行数:21,代码来源:events.ts

示例8: tagForProperty

export function tagForProperty(object: any, propertyKey: string | symbol, _meta?: Meta): Tag {
  if (typeof object !== 'object' || object === null) {
    return CONSTANT_TAG;
  }
  let meta = _meta === undefined ? metaFor(object) : _meta;

  if (isProxy(object)) {
    return tagFor(object, meta);
  }

  let tags = meta.writableTags();
  let tag = tags[propertyKey];
  if (tag) {
    return tag;
  }

  if (EMBER_METAL_TRACKED_PROPERTIES) {
    let pair = combine([makeTag(), UpdatableTag.create(CONSTANT_TAG)]);
    return (tags[propertyKey] = pair);
  } else {
    return (tags[propertyKey] = makeTag());
  }
}
开发者ID:GreatWizard,项目名称:ember.js,代码行数:23,代码来源:tags.ts

示例9: watchKey

export function watchKey(obj: object, keyName: string, _meta?: Meta): void {
  let meta = _meta === undefined ? metaFor(obj) : _meta;
  let count = meta.peekWatching(keyName);
  meta.writeWatching(keyName, count + 1);

  if (count === 0) {
    // activate watching first time
    let possibleDesc = descriptorForProperty(obj, keyName, meta);

    if (possibleDesc !== undefined && possibleDesc.willWatch !== undefined) {
      possibleDesc.willWatch(obj, keyName, meta);
    }

    if (typeof (obj as MaybeHasWillWatchProperty).willWatchProperty === 'function') {
      (obj as MaybeHasWillWatchProperty).willWatchProperty!(keyName);
    }

    if (DEBUG) {
      // NOTE: this is dropped for prod + minified builds
      handleMandatorySetter(meta, obj, keyName);
    }
  }
}
开发者ID:habdelra,项目名称:ember.js,代码行数:23,代码来源:watch_key.ts

示例10: markObjectAsDirty

export function markObjectAsDirty(obj: object, propertyKey: string, _meta?: Meta): void {
  let meta = _meta === undefined ? metaFor(obj) : _meta;
  let objectTag = meta.readableTag();

  if (objectTag !== undefined) {
    if (isProxy(obj)) {
      (objectTag.inner! as any).first.inner.dirty();
    } else {
      (objectTag.inner! as any).dirty();
    }
  }

  let tags = meta.readableTags();
  let propertyTag = tags !== undefined ? tags[propertyKey] : undefined;

  if (propertyTag !== undefined) {
    dirty(propertyTag);
  }

  if (objectTag !== undefined || propertyTag !== undefined) {
    ensureRunloop();
  }
}
开发者ID:emberjs,项目名称:ember.js,代码行数:23,代码来源:tags.ts


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