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


TypeScript internals.guidFor函数代码示例

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


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

示例1: guidFor

    const unload = inverseRecordData => {
      const id = guidFor(inverseRecordData);

      if (this._hasSupportForRelationships(inverseRecordData) && seen[id] === undefined) {
        const relationship = relationshipStateFor(inverseRecordData, this.inverseKey);
        relationship.removeCompletelyFromOwn(recordData);
        seen[id] = true;
      }
    };
开发者ID:code0100fun,项目名称:data,代码行数:9,代码来源:relationship.ts

示例2: guidFor

    .finally(() => {
      let contextGuid = guidFor(context);

      runDestroyablesFor(CLEANUP, contextGuid);

      if (waitForSettled) {
        return settled();
      }

      return nextTickPromise();
    });
开发者ID:switchfly,项目名称:ember-test-helpers,代码行数:11,代码来源:teardown-context.ts

示例3: nextTickPromise

  return nextTickPromise().then(() => {
    let contextGuid = guidFor(context);

    runDestroyablesFor(RENDERING_CLEANUP, contextGuid);

    if (waitForSettled) {
      return settled();
    }

    return nextTickPromise();
  });
开发者ID:switchfly,项目名称:ember-test-helpers,代码行数:11,代码来源:teardown-rendering-context.ts

示例4: forAllMembers

  forAllMembers(callback: (im: RelationshipRecordData) => void) {
    let seen = Object.create(null);

    for (let i = 0; i < this.members.list.length; i++) {
      const inverseInternalModel = this.members.list[i];
      const id = guidFor(inverseInternalModel);
      if (!seen[id]) {
        seen[id] = true;
        callback(inverseInternalModel);
      }
    }

    for (let i = 0; i < this.canonicalMembers.list.length; i++) {
      const inverseInternalModel = this.canonicalMembers.list[i];
      const id = guidFor(inverseInternalModel);
      if (!seen[id]) {
        seen[id] = true;
        callback(inverseInternalModel);
      }
    }
  }
开发者ID:code0100fun,项目名称:data,代码行数:21,代码来源:relationship.ts

示例5: addWithIndex

  addWithIndex(obj: T, idx?: number) {
    let guid = guidFor(obj);
    let presenceSet = this.presenceSet;
    let list = this.list;

    if (presenceSet[guid] === true) {
      return;
    }

    presenceSet[guid] = true;

    if (idx === undefined || idx === null) {
      list.push(obj);
    } else {
      list.splice(idx, 0, obj);
    }

    this.size += 1;

    return this;
  }
开发者ID:code0100fun,项目名称:data,代码行数:21,代码来源:ordered-set.ts

示例6: container

/**
  Used by test framework addons to setup the provided context for rendering.

  `setupContext` must have been ran on the provided context
  prior to calling `setupRenderingContext`.

  Responsible for:

  - Setup the basic framework used for rendering by the
    `render` helper.
  - Ensuring the event dispatcher is properly setup.
  - Setting `this.element` to the root element of the testing
    container (things rendered via `render` will go _into_ this
    element).

  @public
  @param {Object} context the context to setup for rendering
  @returns {Promise<Object>} resolves with the context that was setup
*/
export default function setupRenderingContext(context: TestContext): Promise<RenderingTestContext> {
  let contextGuid = guidFor(context);
  RENDERING_CLEANUP[contextGuid] = [];

  return nextTickPromise()
    .then(() => {
      let { owner } = context;

      // these methods being placed on the context itself will be deprecated in
      // a future version (no giant rush) to remove some confusion about which
      // is the "right" way to things...
      Object.defineProperty(context, 'render', {
        configurable: true,
        enumerable: true,
        value: render,
        writable: false,
      });
      Object.defineProperty(context, 'clearRender', {
        configurable: true,
        enumerable: true,
        value: clearRender,
        writable: false,
      });

      if (global.jQuery) {
        Object.defineProperty(context, '$', {
          configurable: true,
          enumerable: true,
          value: jQuerySelector,
          writable: false,
        });
      }

      // When the host app uses `setApplication` (instead of `setResolver`) the event dispatcher has
      // already been setup via `applicationInstance.boot()` in `./build-owner`. If using
      // `setResolver` (instead of `setApplication`) a "mock owner" is created by extending
      // `Ember._ContainerProxyMixin` and `Ember._RegistryProxyMixin` in this scenario we need to
      // manually start the event dispatcher.
      if (owner._emberTestHelpersMockOwner) {
        let dispatcher =
          owner.lookup('event_dispatcher:main') || (Ember.EventDispatcher as any).create();
        dispatcher.setup({}, '#ember-testing');
      }

      let OutletView = owner.factoryFor
        ? owner.factoryFor('view:-outlet')
        : owner._lookupFactory!('view:-outlet');
      let toplevelView = OutletView.create();

      owner.register('-top-level-view:main', {
        create() {
          return toplevelView;
        },
      });

      // initially render a simple empty template
      return render(EMPTY_TEMPLATE).then(() => {
        (run as Function)(toplevelView, 'appendTo', getRootElement());

        return settled();
      });
    })
    .then(() => {
      Object.defineProperty(context, 'element', {
        configurable: true,
        enumerable: true,
        // ensure the element is based on the wrapping toplevel view
        // Ember still wraps the main application template with a
        // normal tagged view
        //
        // In older Ember versions (2.4) the element itself is not stable,
        // and therefore we cannot update the `this.element` until after the
        // rendering is completed
        value:
          global.EmberENV._APPLICATION_TEMPLATE_WRAPPER !== false
            ? getRootElement().querySelector('.ember-view')
            : getRootElement(),

        writable: false,
      });

//.........这里部分代码省略.........
开发者ID:switchfly,项目名称:ember-test-helpers,代码行数:101,代码来源:setup-rendering-context.ts

示例7: carouselName

 @computed
 get carouselName() : string {
   return guidFor(this) + '-carousel';
 }
开发者ID:pjcarly,项目名称:ember-mist-components,代码行数:4,代码来源:component.ts

示例8: context

/**
  Used by test framework addons to setup the provided context for testing.

  Responsible for:

  - sets the "global testing context" to the provided context (`setContext`)
  - create an owner object and set it on the provided context (e.g. `this.owner`)
  - setup `this.set`, `this.setProperties`, `this.get`, and `this.getProperties` to the provided context
  - setting up AJAX listeners
  - setting up `pauseTest` (also available as `this.pauseTest()`) and `resumeTest` helpers

  @public
  @param {Object} context the context to setup
  @param {Object} [options] options used to override defaults
  @param {Resolver} [options.resolver] a resolver to use for customizing normal resolution
  @returns {Promise<Object>} resolves with the context that was setup
*/
export default function setupContext(
  context: BaseContext,
  options: { resolver?: Resolver } = {}
): Promise<TestContext> {
  (Ember as any).testing = true;
  setContext(context);

  let contextGuid = guidFor(context);
  CLEANUP[contextGuid] = [];

  run.backburner.DEBUG = true;

  return nextTickPromise()
    .then(() => {
      let application = getApplication();
      if (application) {
        return application.boot().then(() => {});
      }
      return;
    })
    .then(() => {
      let testElementContainer = document.getElementById('ember-testing-container')!; // TODO remove "!"
      let fixtureResetValue = testElementContainer.innerHTML;

      // push this into the final cleanup bucket, to be ran _after_ the owner
      // is destroyed and settled (e.g. flushed run loops, etc)
      CLEANUP[contextGuid].push(() => {
        testElementContainer.innerHTML = fixtureResetValue;
      });

      let { resolver } = options;

      // This handles precendence, specifying a specific option of
      // resolver always trumps whatever is auto-detected, then we fallback to
      // the suite-wide registrations
      //
      // At some later time this can be extended to support specifying a custom
      // engine or application...
      if (resolver) {
        return buildOwner(null, resolver);
      }

      return buildOwner(getApplication(), getResolver());
    })
    .then(owner => {
      Object.defineProperty(context, 'owner', {
        configurable: true,
        enumerable: true,
        value: owner,
        writable: false,
      });

      Object.defineProperty(context, 'set', {
        configurable: true,
        enumerable: true,
        value(key: string, value: any): any {
          let ret = run(function() {
            return set(context, key, value);
          });

          return ret;
        },
        writable: false,
      });

      Object.defineProperty(context, 'setProperties', {
        configurable: true,
        enumerable: true,
        value(hash: { [key: string]: any }): { [key: string]: any } {
          let ret = run(function() {
            return setProperties(context, hash);
          });

          return ret;
        },
        writable: false,
      });

      Object.defineProperty(context, 'get', {
        configurable: true,
        enumerable: true,
        value(key: string): any {
          return get(context, key);
//.........这里部分代码省略.........
开发者ID:switchfly,项目名称:ember-test-helpers,代码行数:101,代码来源:setup-context.ts


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