本文整理汇总了TypeScript中@glimmer/object.Mixin类的典型用法代码示例。如果您正苦于以下问题:TypeScript Mixin类的具体用法?TypeScript Mixin怎么用?TypeScript Mixin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mixin类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: foo
QUnit.test('applying several mixins at once with sup already defined causes infinite loop', assert => {
let cnt = 0;
let MixinA = Mixin.create({
foo() { cnt++; }
});
let MixinB = Mixin.create({
foo() {
this._super.apply(this, arguments);
cnt++;
}
});
let MixinC = Mixin.create({
foo() {
this._super.apply(this, arguments);
cnt++;
}
});
let obj = {};
mixin(obj, MixinA); // sup already exists
mixin(obj, MixinB, MixinC); // must be more than one mixin
cnt = 0;
obj['foo']();
assert.equal(cnt, 3, 'should invoke all 3 methods');
});
开发者ID:asakusuma,项目名称:glimmer,代码行数:28,代码来源:ember-mixin-method-test.ts
示例2: meth
QUnit.test('mergedProperties\' overwriting methods can call _super', assert => {
assert.expect(4);
let MixinA = Mixin.create({
mergedProperties: ['foo'],
foo: {
meth(a: string) {
assert.equal(a, 'WOOT', '_super successfully called MixinA\'s `foo.meth` method');
return 'WAT';
}
}
});
let MixinB = Mixin.create({
foo: {
meth() {
assert.ok(true, 'MixinB\'s `foo.meth` method called');
return this._super.apply(this, arguments);
}
}
});
let MixinC = Mixin.create({
foo: {
meth(a: string) {
assert.ok(true, 'MixinC\'s `foo.meth` method called');
return this._super(a);
}
}
});
let obj = mixin({}, MixinA, MixinB, MixinC);
assert.equal(obj.foo.meth('WOOT'), 'WAT');
});
开发者ID:jayphelps,项目名称:glimmer,代码行数:34,代码来源:ember-metal-merged-properties-test.ts
示例3: apply
QUnit.test('detect() finds nested mixins', assert => {
let MixinA = Mixin.create({});
let MixinB = Mixin.create(MixinA);
let obj = {};
assert.equal(MixinA.detect(obj), false, 'MixinA.detect(obj) before apply()');
MixinB.apply(obj);
assert.equal(MixinA.detect(obj), true, 'MixinA.detect(obj) after apply()');
});
开发者ID:asakusuma,项目名称:glimmer,代码行数:10,代码来源:ember-mixin-detect-test.ts
示例4: mixin
QUnit.skip('adding a non-concatenable property that already has a defined value should result in an array with both values', assert => {
let mixinA = Mixin.create({
foo: 1
});
let mixinB = Mixin.create({
concatenatedProperties: ['foo'],
foo: 2
});
let obj = mixin({}, mixinA, mixinB);
assert.deepEqual(get(obj, 'foo'), [1, 2]);
});
开发者ID:asakusuma,项目名称:glimmer,代码行数:13,代码来源:ember-metal-concatenated-properties-test.ts
示例5: mixin
QUnit.test('defining mergedProperties with null properties should keep properties null', assert => {
let MixinA = Mixin.create({
mergedProperties: ['foo'],
foo: null
});
let MixinB = Mixin.create({
foo: null
});
let obj = mixin({}, MixinA, MixinB);
assert.equal(get(obj, 'foo'), null);
});
开发者ID:jayphelps,项目名称:glimmer,代码行数:13,代码来源:ember-metal-merged-properties-test.ts
注:本文中的@glimmer/object.Mixin类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论