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


TypeScript computed.alias函数代码示例

本文整理汇总了TypeScript中@ember/object/computed.alias函数的典型用法代码示例。如果您正苦于以下问题:TypeScript alias函数的具体用法?TypeScript alias怎么用?TypeScript alias使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了alias函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: set

        set(key, value) {
            const [first, last] = value.split(' ');
            this.set('firstName', first);
            this.set('lastName', last);
            return value;
        }
    }),

    combinators: Ember.computed<string>(function() {
        return this.get('firstName');
    }).property('firstName')
      .meta({ foo: 'bar' })
      .volatile()
      .readOnly(),

    explicitlyDeclared: alias('fullName') as Computed<string>,
});

const person = Person.create({
    firstName: 'Fred',
    lastName: 'Smith',
    age: 29,
});

assertType<string>(person.firstName);
assertType<number>(person.age);
assertType<Ember.ComputedProperty<string>>(person.noArgs);
assertType<Ember.ComputedProperty<string>>(person.fullName);
assertType<Ember.ComputedProperty<string>>(person.fullNameReadonly);
assertType<Ember.ComputedProperty<string>>(person.fullNameWritable);
assertType<Ember.ComputedProperty<string>>(person.fullNameGetOnly);
开发者ID:AlexGalays,项目名称:DefinitelyTyped,代码行数:31,代码来源:computed.ts

示例2: service

import { alias } from '@ember/object/computed';

export default Mixin.create({
  /**
   * The AJAX service to send requests through
   *
   * @property {AjaxService} ajaxService
   * @public
   */
  ajaxService: service('ajax'),

  /**
   * @property {string} host
   * @public
   */
  host: alias('ajaxService.host'),

  /**
   * @property {string} namespace
   * @public
   */
  namespace: alias('ajaxService.namespace'),

  /**
   * @property {object} headers
   * @public
   */
  headers: alias('ajaxService.headers'),

  ajax(url: string, _method: string, _options: object) {
    // @ts-ignore
开发者ID:knownasilya,项目名称:ember-ajax,代码行数:31,代码来源:ajax-support.ts

示例3: set

        set(key, value) {
            const [first, last] = value.split(' ');
            this.set('firstName', first);
            this.set('lastName', last);
            return value;
        }
    }),

    combinators: computed<string>(function() {
        return this.get('firstName');
    }).property('firstName')
      .meta({ foo: 'bar' })
      .volatile()
      .readOnly(),

    explicitlyDeclared: alias('fullName') as ComputedProperty<string>,
});

const person = Person.create({
    firstName: 'Fred',
    lastName: 'Smith',
    age: 29,
});

assertType<string>(person.firstName);
assertType<number>(person.age);
assertType<ComputedProperty<string>>(person.noArgs);
assertType<ComputedProperty<string>>(person.fullName);
assertType<ComputedProperty<string>>(person.fullNameReadonly);
assertType<ComputedProperty<string>>(person.fullNameWritable);
assertType<ComputedProperty<string>>(person.fullNameGetOnly);
开发者ID:AlexGalays,项目名称:DefinitelyTyped,代码行数:31,代码来源:computed.ts


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