本文整理汇总了TypeScript中@ember/-internals/owner.getOwner函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getOwner函数的具体用法?TypeScript getOwner怎么用?TypeScript getOwner使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getOwner函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
let getInjection = function(this: any, propertyName: string) {
let owner = getOwner(this) || this.container; // fallback to `container` for backwards compat
assert(
`Attempting to lookup an injected property on an object without a container, ensure that the object was instantiated via a container.`,
Boolean(owner)
);
return owner.lookup(`${type}:${name || propertyName}`, { source, namespace });
};
示例2: getOwner
!(() => {
let eventDispatcher = getOwner(this).lookup<any | undefined>('event_dispatcher:main');
let events = (eventDispatcher && eventDispatcher._finalEvents) || {};
// tslint:disable-next-line:forin
for (let key in events) {
let methodName = events[key];
if (typeof this[methodName] === 'function') {
return true; // indicate that the assertion should be triggered
}
}
return false;
})()
示例3: injectedPropertyGet
function injectedPropertyGet(this: any, keyName: string): any {
let desc = descriptorFor(this, keyName);
let owner = getOwner(this) || this.container; // fallback to `container` for backwards compat
assert(
`InjectedProperties should be defined with the inject computed property macros.`,
desc && desc.type
);
assert(
`Attempting to lookup an injected property on an object without a container, ensure that the object was instantiated via a container.`,
!!owner
);
let specifier = `${desc.type}:${desc.name || keyName}`;
return owner.lookup(specifier, {
source: desc.source,
namespace: desc.namespace,
});
}
示例4: prefixRouteNameArg
export function prefixRouteNameArg(route: Route, args: any[]) {
let routeName = args[0];
let owner = getOwner(route);
let prefix = owner.mountPoint;
// only alter the routeName if it's actually referencing a route.
if (owner.routable && typeof routeName === 'string') {
if (resemblesURL(routeName)) {
throw new EmberError(
'Programmatic transitions by URL cannot be used within an Engine. Please use the route name instead.'
);
} else {
routeName = `${prefix}.${routeName}`;
args[0] = routeName;
}
}
return args;
}
示例5: init
Input = Component.extend({
tagName: '',
init() {
if (DEBUG) {
this[DISABLE_TAGLESS_EVENT_CHECK] = true;
}
this._super(...arguments);
},
isCheckbox: computed('type', function(this: { type?: unknown }) {
return this.type === 'checkbox';
}),
__injectEvents(target: any) {
let eventDispatcher = getOwner(this).lookup<any | undefined>('event_dispatcher:main');
let events: Dict<string> = (eventDispatcher && eventDispatcher._finalEvents) || {};
Object.values(events).forEach(key => {
if (this[key]) {
target[key] = this[key];
}
});
},
});
Input.toString = () => '@ember/component/input';
if (DEBUG) {
const UNSET = {};
Input.reopen({
示例6: create
create(injections: Injections): OwnedTemplate {
const owner = getOwner(injections);
return this.factory.create(injections.compiler, { owner });
}