• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript ember.Object类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testObserver

function testObserver() {
    Ember.Object.extend({
        valueObserver: Ember.observer('value', function() {
            // Executes whenever the "value" property changes
        })
    });
}
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:7,代码来源:event.ts


示例2: testOn

function testOn() {
    let Job = Ember.Object.extend({
        logCompleted: Ember.on('completed', function() {
            console.log('Job completed!');
        })
    });

    let job = Job.create();

    Ember.sendEvent(job, 'completed'); // Logs 'Job completed!'
}
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:11,代码来源:event.ts


示例3: String

(() => {
    /** typeOf */
    Ember.typeOf();                       // $ExpectType "undefined"
    Ember.typeOf(null);                   // $ExpectType "null"
    Ember.typeOf(undefined);              // $ExpectType "undefined"
    Ember.typeOf('michael');              // $ExpectType "string"
    // tslint:disable-next-line:no-construct
    Ember.typeOf(new String('michael'));  // $ExpectType "string"
    Ember.typeOf(101);                    // $ExpectType "number"
    // tslint:disable-next-line:no-construct
    Ember.typeOf(new Number(101));        // $ExpectType "number"
    Ember.typeOf(true);                   // $ExpectType "boolean"
    // tslint:disable-next-line:no-construct
    Ember.typeOf(new Boolean(true));      // $ExpectType "boolean"
    Ember.typeOf(() => 4);                // $ExpectType "function"
    Ember.typeOf([1, 2, 90]);             // $ExpectType "array"
    Ember.typeOf(/abc/);                  // $ExpectType "regexp"
    Ember.typeOf(new Date());             // $ExpectType "date"
    Ember.typeOf(({} as any) as FileList);  // $ExpectType "filelist"
    Ember.typeOf(Ember.Object.extend());   // $ExpectType "class"
    Ember.typeOf(Ember.Object.create());   // $ExpectType "instance"
    Ember.typeOf(new Error('teamocil'));  // $ExpectType "error"
    Ember.typeOf((new Date()) as RegExp | Date); // "regexp" | "date"
})();
开发者ID:AlexGalays,项目名称:DefinitelyTyped,代码行数:24,代码来源:utils.ts


示例4: testEvented

function testEvented() {
    let Person = Ember.Object.extend(Ember.Evented, {
        greet() {
            this.trigger('greet');
        }
    });

    let person = Person.create();

    person.on('greet', function() {
        console.log('Our person has greeted');
    });

    person.on('greet', function() {
        console.log('Our person has greeted');
    }).one('greet', function() {
        console.log('Offer one-time special');
    }).off('event', {}, function() {});

    person.greet();
}
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:21,代码来源:event.ts


示例5: createMan

import Ember from 'ember';

let App: any;

App = Ember.Application.create();
App.president = Ember.Object.create({
    name: 'Barack Obama',
});
App.country = Ember.Object.create({
    presidentNameBinding: 'MyApp.president.name',
});
App.country.get('presidentName');
App.president = Ember.Object.create({
    firstName: 'Barack',
    lastName: 'Obama',
    fullName: Ember.computed(function() {
        return `${this.get('firstName')} ${this.get('lastName')}`;
    }),
});
App.president.get('fullName');

declare class MyPerson extends Ember.Object {
    static createMan(): MyPerson;
}
MyPerson.createMan();

const Person1 = Ember.Object.extend({
    say: (thing: string) => {
        alert(thing);
    },
});
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:31,代码来源:ember-tests.ts


示例6:

import Ember from 'ember';
import { assertType } from './lib/assert';

const ExtendClass = Ember.Object.extend({
    foo: 'hello'
});

class ES6Class extends Ember.Object {
    bar: string;
}

let TestClass = Ember.Object;

if (ExtendClass.detect(TestClass)) {
    assertType<string>(TestClass.create().foo);
}

if (ES6Class.detect(TestClass)) {
    assertType<string>(TestClass.create().bar);
}
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:20,代码来源:detect.ts


示例7: function

const Person = Ember.Object.extend({
    firstName: '',
    lastName: '',
    age: 0,

    noArgs: Ember.computed<string>(() => 'test'),

    fullName: Ember.computed<string>('firstName', 'lastName', function() {
        return `${this.get('firstName')} ${this.get('lastName')}`;
    }),

    fullNameReadonly: Ember.computed<string>('fullName', function() {
        return this.get('fullName');
    }).readOnly(),

    fullNameWritable: Ember.computed<string>('firstName', 'lastName', {
        get() {
            return this.get('fullName');
        },
        set(key, value) {
            const [first, last] = value.split(' ');
            this.set('firstName', first);
            this.set('lastName', last);
            return value;
        }
    }),

    fullNameGetOnly: Ember.computed<string>('fullName', {
        get() {
            return this.get('fullName');
        }
    }),

    fullNameSetOnly: Ember.computed<string>('firstName', 'lastName', {
        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>,
});
开发者ID:AlexGalays,项目名称:DefinitelyTyped,代码行数:51,代码来源:computed.ts


示例8:

            this.edit();
        }
    }
});

const comment = EditableComment.create({
    postId: 42
});

comment.edit();
comment.canEdit();
comment.tryEdit();
assertType<boolean>(comment.isEditing);
assertType<number>(comment.postId);

const LiteralMixins = Ember.Object.extend({ a: 1 }, { b: 2 }, { c: 3 });
const obj = LiteralMixins.create();
assertType<number>(obj.a);
assertType<number>(obj.b);
assertType<number>(obj.c);

/* Test composition of mixins */
const EditableAndCancelableMixin = Ember.Mixin.create(EditableMixin, {
    cancelled: false,
});

const EditableAndCancelableComment = Ember.Route.extend(EditableAndCancelableMixin);

const editableAndCancelable = EditableAndCancelableComment.create();
assertType<boolean>(editableAndCancelable.isEditing);
assertType<boolean>(editableAndCancelable.cancelled);
开发者ID:AlexGalays,项目名称:DefinitelyTyped,代码行数:31,代码来源:mixin.ts


示例9:

import Ember from 'ember';
import { assertType } from './lib/assert';

type Person = typeof Person.prototype;
const Person = Ember.Object.extend({
    name: '',
    isHappy: false
});

const people = Ember.A([
    Person.create({ name: 'Yehuda', isHappy: true }),
    Person.create({ name: 'Majd', isHappy: false }),
]);

assertType<number>(people.get('length'));
assertType<Person>(people.get('lastObject'));
assertType<boolean>(people.isAny('isHappy'));
assertType<boolean>(people.isAny('isHappy', 'false'));
assertType<Ember.Enumerable<Person>>(people.filterBy('isHappy'));
assertType<Ember.Enumerable<Person>>(people.rejectBy('isHappy'));
assertType<Ember.Enumerable<Person>>(people.filter((person) => person.get('name') === 'Yehuda'));
assertType<typeof people>(people.get('[]'));
assertType<Person>(people.get('[]').get('firstObject'));

assertType<Ember.Array<boolean>>(people.mapBy('isHappy'));
assertType<any[]>(people.mapBy('name.length'));

const last = people.get('lastObject');
if (last) {
    assertType<string>(last.get('name'));
}
开发者ID:AlexGalays,项目名称:DefinitelyTyped,代码行数:31,代码来源:array.ts


示例10: init

import Ember from 'ember';

const LifetimeHooks = Ember.Object.extend({
    resource: null as {} | null,

    init() {
        this._super();
        this.resource = {};
    },

    willDestroy() {
        delete this.resource;
        this._super();
    }
});
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:15,代码来源:object.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript ember.Route类代码示例发布时间:2022-05-25
下一篇:
TypeScript ember.Mixin类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap