當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Meta.peekWatching方法代碼示例

本文整理匯總了TypeScript中@ember/-internals/meta.Meta.peekWatching方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Meta.peekWatching方法的具體用法?TypeScript Meta.peekWatching怎麽用?TypeScript Meta.peekWatching使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在@ember/-internals/meta.Meta的用法示例。


在下文中一共展示了Meta.peekWatching方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: setup

 setup(obj: object, keyName: string, meta: Meta): void {
   assert(`Setting alias '${keyName}' on self`, this.altKey !== keyName);
   super.setup(obj, keyName, meta);
   if (meta.peekWatching(keyName) > 0) {
     this.consume(obj, keyName, meta);
   }
 }
開發者ID:Turbo87,項目名稱:ember.js,代碼行數:7,代碼來源:alias.ts

示例2: setup

  setup(obj: object, keyName: string, propertyDesc: PropertyDescriptor, meta: Meta): void {
    assert(`Setting alias '${keyName}' on self`, this.altKey !== keyName);
    super.setup(obj, keyName, propertyDesc, meta);

    if (!EMBER_METAL_TRACKED_PROPERTIES && meta.peekWatching(keyName) > 0) {
      this.consume(obj, keyName, meta);
    }
  }
開發者ID:emberjs,項目名稱:ember.js,代碼行數:8,代碼來源:alias.ts

示例3: unconsume

 unconsume(obj: object, keyName: string, meta: Meta): void {
   let wasConsumed = getCachedValueFor(obj, keyName) === CONSUMED;
   if (wasConsumed || meta.peekWatching(keyName) > 0) {
     removeDependentKeys(this, obj, keyName, meta);
   }
   if (wasConsumed) {
     getCacheFor(obj).delete(keyName);
   }
 }
開發者ID:cibernox,項目名稱:ember.js,代碼行數:9,代碼來源:alias.ts

示例4: defineProperty

export function defineProperty(
  obj: object,
  keyName: string,
  desc?: Decorator | undefined | null,
  data?: any | undefined | null,
  meta?: Meta
): void {
  if (meta === undefined) {
    meta = metaFor(obj);
  }

  let watching = meta.peekWatching(keyName) > 0;
  let previousDesc = descriptorForProperty(obj, keyName, meta);
  let wasDescriptor = previousDesc !== undefined;

  if (wasDescriptor) {
    previousDesc.teardown(obj, keyName, meta);
  }

  // used to track if the the property being defined be enumerable
  let enumerable = true;

  // Ember.NativeArray is a normal Ember.Mixin that we mix into `Array.prototype` when prototype extensions are enabled
  // mutating a native object prototype like this should _not_ result in enumerable properties being added (or we have significant
  // issues with things like deep equality checks from test frameworks, or things like jQuery.extend(true, [], [])).
  //
  // this is a hack, and we should stop mutating the array prototype by default 😫
  if (obj === Array.prototype) {
    enumerable = false;
  }

  let value;
  if (isComputedDecorator(desc)) {
    let elementDesc = {
      key: keyName,
      kind: 'field',
      placement: 'own',
      descriptor: {
        value: undefined,
      },
      toString() {
        return '[object Descriptor]';
      },
    } as ElementDescriptor;

    if (DEBUG) {
      elementDesc = desc!(elementDesc, true);
    } else {
      elementDesc = desc!(elementDesc);
    }

    Object.defineProperty(obj, keyName, elementDesc.descriptor);

    if (elementDesc.finisher !== undefined) {
      if (obj.constructor !== undefined && obj.constructor.prototype === obj) {
        // Nonstandard, we push the meta along here
        elementDesc.finisher(obj.constructor, meta);
      } else {
        // The most correct thing to do here is only pass the constructor of the
        // object to the finisher, but we have to support being able to
        // `defineProperty` directly on instances as well. This is _not_ spec
        // compliant, but it's limited to core decorators that work with the
        // classic object model.
        elementDesc.finisher(obj, meta);
      }
    }

    // pass the decorator function forward for backwards compat
    value = desc;
  } else if (desc === undefined || desc === null) {
    value = data;

    if (DEBUG && watching) {
      meta.writeValues(keyName, data);

      let defaultDescriptor = {
        configurable: true,
        enumerable,
        set: MANDATORY_SETTER_FUNCTION(keyName),
        get: DEFAULT_GETTER_FUNCTION(keyName),
      };

      Object.defineProperty(obj, keyName, defaultDescriptor);
    } else if (wasDescriptor || enumerable === false) {
      Object.defineProperty(obj, keyName, {
        configurable: true,
        enumerable,
        writable: true,
        value,
      });
    } else {
      obj[keyName] = data;
    }
  } else {
    value = desc;

    // fallback to ES5
    Object.defineProperty(obj, keyName, desc);
  }

//.........這裏部分代碼省略.........
開發者ID:jaswilli,項目名稱:ember.js,代碼行數:101,代碼來源:properties.ts

示例5: defineProperty

export function defineProperty(
  obj: object,
  keyName: string,
  desc: Descriptor | undefined | null,
  data?: any | undefined | null,
  meta?: Meta
) {
  if (meta === undefined) {
    meta = metaFor(obj);
  }

  let watching = meta.peekWatching(keyName) > 0;
  let previousDesc = descriptorFor(obj, keyName, meta);
  let wasDescriptor = previousDesc !== undefined;

  if (wasDescriptor) {
    previousDesc.teardown(obj, keyName, meta);
    meta.removeDescriptors(keyName);
  }

  // used to track if the the property being defined be enumerable
  let enumerable = true;

  // Ember.NativeArray is a normal Ember.Mixin that we mix into `Array.prototype` when prototype extensions are enabled
  // mutating a native object prototype like this should _not_ result in enumerable properties being added (or we have significant
  // issues with things like deep equality checks from test frameworks, or things like jQuery.extend(true, [], [])).
  //
  // this is a hack, and we should stop mutating the array prototype by default 😫
  if (obj === Array.prototype) {
    enumerable = false;
  }

  let value;
  if (desc instanceof Descriptor) {
    value = desc;

    Object.defineProperty(obj, keyName, {
      configurable: true,
      enumerable,
      get: DESCRIPTOR_GETTER_FUNCTION(keyName, value),
    });

    meta.writeDescriptors(keyName, value);

    desc.setup(obj, keyName);
  } else if (desc === undefined || desc === null) {
    value = data;

    if (DEBUG && watching) {
      meta.writeValues(keyName, data);

      let defaultDescriptor = {
        configurable: true,
        enumerable,
        set: MANDATORY_SETTER_FUNCTION(keyName),
        get: DEFAULT_GETTER_FUNCTION(keyName),
      };

      Object.defineProperty(obj, keyName, defaultDescriptor);
    } else if (wasDescriptor || enumerable === false) {
      Object.defineProperty(obj, keyName, {
        configurable: true,
        enumerable,
        writable: true,
        value,
      });
    } else {
      obj[keyName] = data;
    }
  } else {
    value = desc;

    // fallback to ES5
    Object.defineProperty(obj, keyName, desc);
  }

  // if key is being watched, override chains that
  // were initialized with the prototype
  if (watching) {
    overrideChains(obj, keyName, meta);
  }

  // The `value` passed to the `didDefineProperty` hook is
  // either the descriptor or data, whichever was passed.
  if (typeof (obj as ExtendedObject).didDefineProperty === 'function') {
    (obj as ExtendedObject).didDefineProperty!(obj, keyName, value);
  }
}
開發者ID:knownasilya,項目名稱:ember.js,代碼行數:88,代碼來源:properties.ts

示例6: teardown

 teardown(obj: object, keyName: string, meta: Meta): void {
   if (meta.peekWatching(keyName) > 0) {
     removeDependentKeys(this, obj, keyName, meta);
   }
 }
開發者ID:knownasilya,項目名稱:ember.js,代碼行數:5,代碼來源:alias.ts


注:本文中的@ember/-internals/meta.Meta.peekWatching方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。