本文整理汇总了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;
}
示例2: constructor
constructor(...args: any[]) {
super(...args);
setOwner(this, owner);
}
示例3: create
static create(injections: StoreSettings) {
const owner = getOwner(injections);
const store = new this(injections);
setOwner(store, owner);
return store;
}