本文整理汇总了TypeScript中@ember/application.getOwner函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getOwner函数的具体用法?TypeScript getOwner怎么用?TypeScript getOwner使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getOwner函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: beforeModel
async beforeModel() {
await runMigrations(getOwner(this));
await ensureRelays(getOwner(this));
// TODO: check all the modern web requirements
await this.locale.setLocale(this.locale.currentLocale);
await this.currentUser.load();
}
示例2: get
cachedFirestoreInstance = app.firestore().then(firestore => {
const settings = get(adapter, 'settings');
firestore.settings(settings);
const enablePersistence = get(adapter, 'enablePersistence');
const fastboot = getOwner(adapter).lookup('service:fastboot');
if (enablePersistence && (fastboot == null || !fastboot.isFastBoot)) {
const persistenceSettings = get(adapter, 'persistenceSettings');
firestore.enablePersistence(persistenceSettings).catch(console.warn);
}
return firestore;
});
示例3: modelFactoryFor
private modelFactoryFor(type: string) {
let modelFactory = this._modelFactoryMap[type];
if (!modelFactory) {
let owner = getOwner(this._store);
let orbitConfig = owner.lookup('ember-orbit:config');
modelFactory = owner.factoryFor(`${orbitConfig.types.model}:${type}`);
this._modelFactoryMap[type] = modelFactory;
}
return modelFactory;
}
示例4: mountElement
private mountElement() {
const props = this.getPropsForReact();
let { children } = props;
if (!children) {
const childNodes = this.element.childNodes;
children = [
React.createElement(YieldWrapper, {
key: get(this, 'elementId'),
nodes: [...childNodes]
})
];
}
const owner = getOwner(this);
const KlassWithOwner = grantOwnerAccess(Klass, owner);
ReactDOM.render(
React.createElement(KlassWithOwner, props, children),
this.element
);
}
示例5: config
/**
* Returns the config for this application
*/
@computed
get config() : any {
return getOwner(this).resolveRegistration('config:environment');
}
示例6: getOwner
const isFastboot = (object:Object) => {
const fastboot = getOwner(object).lookup('service:fastboot');
return fastboot && fastboot.isFastBoot;
}
示例7: 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;
}
示例8: provider
@computed('src')
get provider(): Provider {
return getOwner(this).lookup('ember-oembed:provider-for-url')(this.get('src'));
}
示例9: endpoint
/**
* Get the endpoint from the config
*/
@computed
get endpoint() {
const config = getOwner(this).resolveRegistration('config:environment');
return config.apiEndpoint;
}