本文整理汇总了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);
}
示例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);
}
}
示例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);
}
}
示例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);
})()
);
}