本文整理汇总了TypeScript中glimmer-object.extend函数的典型用法代码示例。如果您正苦于以下问题:TypeScript extend函数的具体用法?TypeScript extend怎么用?TypeScript extend使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了extend函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: computed
QUnit.test('reopening a parent with a computed property flushes the child', assert => {
let MyClass = EmberObject.extend({
hello: computed(function() {
return "original hello";
})
});
let SubClass = MyClass.extend({
hello: computed(function() {
return this._super();
})
});
let GrandChild = SubClass.extend({
hello: computed(function() {
return this._super();
})
});
MyClass.reopen({
hello: computed(function() {
return this._super() + " new hello";
})
});
let sub: any = GrandChild.create();
assert.equal(sub.hello, "original hello new hello");
});
开发者ID:GCheung55,项目名称:glimmer,代码行数:29,代码来源:ember-create-test.ts
示例2: function
QUnit.test('Sub-subclass', function() {
let SomeClass = EmberObject.extend({ foo: 'BAR' });
let AnotherClass = SomeClass.extend({ bar: 'FOO' });
let obj: any = new AnotherClass();
equal(obj.foo, 'BAR');
equal(obj.bar, 'FOO');
});
开发者ID:GCheung55,项目名称:glimmer,代码行数:7,代码来源:ember-extend-test.ts
示例3: function
QUnit.test('property name is the same as own prototype property', function() {
let MyClass = EmberObject.extend({
toString() { return 'MyClass'; }
});
equal(MyClass.create().toString(), 'MyClass', 'should inherit property from the arguments of `EmberObject.create`');
});
开发者ID:GCheung55,项目名称:glimmer,代码行数:7,代码来源:ember-create-test.ts
示例4: reopen
QUnit.test('using reopen() and calling _super where there is not a super function does not cause infinite recursion', function() {
let Taco = EmberObject.extend({
createBreakfast() {
// There is no original createBreakfast function.
// Calling the wrapped _super function here
// used to end in an infinite call loop
this._super.apply(this, arguments);
return 'Breakfast!';
}
});
Taco.reopen({
createBreakfast() {
return this._super.apply(this, arguments);
}
});
let taco: any = Taco.create();
let result;
try {
result = taco.createBreakfast();
} catch(e) {
result = 'Your breakfast was interrupted by an infinite stack error.';
throw e;
}
equal(result, 'Breakfast!');
});
开发者ID:GCheung55,项目名称:glimmer,代码行数:29,代码来源:ember-metal-mixin-reopen-test.ts
示例5: function
QUnit.test('adds new properties to subclass', function() {
let Subclass: any = EmberObject.extend();
Subclass.reopenClass({
foo() { return 'FOO'; },
bar: 'BAR'
});
equal(Subclass.foo(), 'FOO', 'Adds method');
equal(get(Subclass, 'bar'), 'BAR', 'Adds property');
});
开发者ID:GCheung55,项目名称:glimmer,代码行数:10,代码来源:ember-reopen-class-test.ts
示例6: function
QUnit.test('adds new properties to subclass instance', function() {
let Subclass = EmberObject.extend();
Subclass.reopen({
foo() { return 'FOO'; },
bar: 'BAR'
});
equal(new Subclass()['foo'](), 'FOO', 'Adds method');
equal(get(new Subclass(), 'bar'), 'BAR', 'Adds property');
});
开发者ID:GCheung55,项目名称:glimmer,代码行数:10,代码来源:ember-reopen-test.ts
注:本文中的glimmer-object.extend函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论