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


TypeScript application.setOwner函数代码示例

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


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

示例1: getRecord

  getRecord(properties?) {
    if (!this._record && !this._isDematerializing) {
      let { store } = this;

      // lookupFactory should really return an object that creates
      // instances with the injections applied
      let createOptions: any = {
        store,
        _internalModel: this,
        currentState: this.currentState,
        isError: this.isError,
        adapterError: this.error,
      };

      if (properties !== undefined) {
        assert(
          `You passed '${properties}' as properties for record creation instead of an object.`,
          typeof properties === 'object' && properties !== null
        );

        if ('id' in properties) {
          this.setId(properties.id);
        }

        // convert relationship Records to RecordDatas before passing to RecordData
        let defs = store._relationshipsDefinitionFor(this.modelName);

        if (defs !== null) {
          let keys = Object.keys(properties);
          let relationshipValue;

          for (let i = 0; i < keys.length; i++) {
            let prop = keys[i];
            let def = defs[prop];

            if (def !== undefined) {
              if (def.kind === 'hasMany') {
                if (DEBUG) {
                  assertRecordsPassedToHasMany(properties[prop]);
                }
                relationshipValue = extractRecordDatasFromRecords(properties[prop]);
              } else {
                relationshipValue = extractRecordDataFromRecord(properties[prop]);
              }

              properties[prop] = relationshipValue;
            }
          }
        }
      }

      let additionalCreateOptions = this._recordData._initRecordCreateOptions(properties);
      assign(createOptions, additionalCreateOptions);

      if (setOwner) {
        // ensure that `getOwner(this)` works inside a model instance
        setOwner(createOptions, getOwner(store));
      } else {
        createOptions.container = store.container;
      }

      this._record = store._modelFactoryFor(this.modelName).create(createOptions);

      this._triggerDeferredTriggers();
    }

    return this._record;
  }
开发者ID:emberjs,项目名称:data,代码行数:68,代码来源:internal-model.ts

示例2: constructor

    constructor(...args: any[]) {
      super(...args);

      setOwner(this, owner);
    }
开发者ID:dfreeman,项目名称:ember-cli-react,代码行数:5,代码来源:grant-owner-access.ts

示例3: create

 static create(injections: StoreSettings) {
   const owner = getOwner(injections);
   const store = new this(injections);
   setOwner(store, owner);
   return store;
 }
开发者ID:orbitjs,项目名称:ember-orbit,代码行数:6,代码来源:store.ts


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