当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript owner.getOwner函数代码示例

本文整理汇总了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 });
  };
开发者ID:cibernox,项目名称:ember.js,代码行数:10,代码来源:injected_property.ts

示例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;
          })()
开发者ID:GreatWizard,项目名称:ember.js,代码行数:14,代码来源:component.ts

示例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,
  });
}
开发者ID:GreatWizard,项目名称:ember.js,代码行数:19,代码来源:injected_property.ts

示例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;
}
开发者ID:Turbo87,项目名称:ember.js,代码行数:19,代码来源:utils.ts

示例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({
开发者ID:mixonic,项目名称:ember.js,代码行数:31,代码来源:input.ts

示例6: create

 create(injections: Injections): OwnedTemplate {
   const owner = getOwner(injections);
   return this.factory.create(injections.compiler, { owner });
 }
开发者ID:GreatWizard,项目名称:ember.js,代码行数:4,代码来源:template.ts


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