• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript debug.inspect函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: _unhandledEvent

  _unhandledEvent(state, name, context) {
    let errorMessage = 'Attempted to handle event `' + name + '` ';
    errorMessage += 'on ' + String(this) + ' while in state ';
    errorMessage += state.stateName + '. ';

    if (context !== undefined) {
      errorMessage += 'Called with ' + inspect(context) + '.';
    }

    throw new EmberError(errorMessage);
  }
开发者ID:emberjs,项目名称:data,代码行数:11,代码来源:internal-model.ts


示例2: _setupRelationships

  _setupRelationships(data) {
    let relationships = this.storeWrapper.relationshipsDefinitionFor(this.modelName);
    let keys = Object.keys(relationships);
    for (let i = 0; i < keys.length; i++) {
      let relationshipName = keys[i];

      if (!data.relationships[relationshipName]) {
        continue;
      }

      // in debug, assert payload validity eagerly
      let relationshipData = data.relationships[relationshipName];

      if (DEBUG) {
        let store = this.store;
        let recordData = this;
        let relationshipMeta = relationships[relationshipName];
        if (!relationshipData || !relationshipMeta) {
          continue;
        }

        if (relationshipData.links) {
          let isAsync = relationshipMeta.options && relationshipMeta.options.async !== false;
          let relationship = this._relationships.get(relationshipName);
          warn(
            `You pushed a record of type '${
              this.modelName
            }' with a relationship '${relationshipName}' configured as 'async: false'. You've included a link but no primary data, this may be an error in your payload. EmberData will treat this relationship as known-to-be-empty.`,
            isAsync || relationshipData.data || relationship.hasAnyRelationshipData,
            {
              id: 'ds.store.push-link-for-sync-relationship',
            }
          );
        } else if (relationshipData.data) {
          if (relationshipMeta.kind === 'belongsTo') {
            assert(
              `A ${
                this.modelName
              } record was pushed into the store with the value of ${relationshipName} being ${inspect(
                relationshipData.data
              )}, but ${relationshipName} is a belongsTo relationship so the value must not be an array. You should probably check your data payload or serializer.`,
              !Array.isArray(relationshipData.data)
            );
            assertRelationshipData(store, recordData, relationshipData.data, relationshipMeta);
          } else if (relationshipMeta.kind === 'hasMany') {
            assert(
              `A ${
                this.modelName
              } record was pushed into the store with the value of ${relationshipName} being '${inspect(
                relationshipData.data
              )}', but ${relationshipName} is a hasMany relationship so the value must be an array. You should probably check your data payload or serializer.`,
              Array.isArray(relationshipData.data)
            );
            if (Array.isArray(relationshipData.data)) {
              for (let i = 0; i < relationshipData.data.length; i++) {
                assertRelationshipData(
                  store,
                  recordData,
                  relationshipData.data[i],
                  relationshipMeta
                );
              }
            }
          }
        }
      }

      let relationship = this._relationships.get(relationshipName);

      relationship.push(relationshipData);
    }
  }
开发者ID:code0100fun,项目名称:data,代码行数:72,代码来源:record-data.ts


示例3: updateData

  updateData(data: JsonApiResourceIdentity, initial: boolean) {
    let recordData;
    if (isNone(data)) {
      recordData = null;
    }
    assert(
      `Ember Data expected the data for the ${
        this.key
      } relationship on a ${this.recordData.toString()} to be in a JSON API format and include an \`id\` and \`type\` property but it found ${inspect(
        data
      )}. Please check your serializer and make sure it is serializing the relationship payload into a JSON API format.`,
      data === null || (data.id !== undefined && data.type !== undefined)
    );

    if (recordData !== null) {
      recordData = this.recordData.storeWrapper.recordDataFor(data.type, (data.id as string));
    }
    if (initial) {
      this.setInitialCanonicalRecordData(recordData);
    } else {
      this.setCanonicalRecordData(recordData);
    }
  }
开发者ID:code0100fun,项目名称:data,代码行数:23,代码来源:belongs-to.ts


示例4: assertRecordsPassedToHasMany

function assertRecordsPassedToHasMany(records) {
  // TODO only allow native arrays
  assert(
    `You must pass an array of records to set a hasMany relationship`,
    Array.isArray(records) || EmberArray.detect(records)
  );
  assert(
    `All elements of a hasMany relationship must be instances of DS.Model, you passed ${inspect(
      records
    )}`,
    (function() {
      return A(records).every(record => record.hasOwnProperty('_internalModel') === true);
    })()
  );
}
开发者ID:emberjs,项目名称:data,代码行数:15,代码来源:internal-model.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript debug.warn函数代码示例发布时间:2022-05-28
下一篇:
TypeScript debug.deprecate函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap