當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。