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


TypeScript glimmer-object.Mixin类代码示例

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


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

示例1: function

QUnit.test('adding a prop that is not an array should make array', function() {
  let MixinA = Mixin.create({
    concatenatedProperties: ['foo'],
    foo: 'bar'
  });

  let obj = mixin({}, MixinA);
  deepEqual(get(obj, 'foo'), ['bar']);
});
开发者ID:GCheung55,项目名称:glimmer,代码行数:9,代码来源:ember-metal-concatenated-properties-test.ts

示例2: function

QUnit.test('detect() finds a directly applied mixin', function() {
  let MixinA = Mixin.create();
  let obj = {};

  equal(MixinA.detect(obj), false, 'MixinA.detect(obj) before apply()');

  MixinA.apply(obj);
  equal(MixinA.detect(obj), true, 'MixinA.detect(obj) after apply()');
});
开发者ID:GCheung55,项目名称:glimmer,代码行数:9,代码来源:ember-mixin-detect-test.ts

示例3: reopen

QUnit.test('using reopen() to add more properties to a simple', function() {
  let MixinA = Mixin.create({ foo: 'FOO', baz: 'BAZ' });
  MixinA.reopen({ bar: 'BAR', foo: 'FOO2' });
  let obj = {};
  MixinA.apply(obj);

  equal(get(obj, 'foo'), 'FOO2', 'mixin() should override');
  equal(get(obj, 'baz'), 'BAZ', 'preserve MixinA props');
  equal(get(obj, 'bar'), 'BAR', 'include MixinB props');
});
开发者ID:GCheung55,项目名称:glimmer,代码行数:10,代码来源:ember-metal-mixin-reopen-test.ts

示例4: adder

QUnit.skip('throws if you try to \'mixin\' a definition', assert => {
  let myMixin = Mixin.create({
    adder(arg1, arg2) {
      return arg1 + arg2;
    }
  });

  assert.throws(function() {
    EmberObject.create(myMixin);
  }, 'Ember.Object.create no longer supports mixing in other definitions, use .extend & .create seperately instead.');
});
开发者ID:GCheung55,项目名称:glimmer,代码行数:11,代码来源:ember-create-test.ts

示例5: function

QUnit.test('mergedProperties should be concatenated', function() {
  let MixinA = Mixin.create({
    mergedProperties: ['foo'],
    foo: { a: true, b: true, c: true }
  });

  let MixinB = Mixin.create({
    mergedProperties: 'bar',
    foo: { d: true, e: true, f: true },
    bar: { a: true, l: true }
  });

  let MixinC = Mixin.create({
    bar: { e: true, x: true }
  });

  let obj = mixin({}, MixinA, MixinB, MixinC);
  deepEqual(get(obj, 'mergedProperties'), ['foo', 'bar'], 'get mergedProperties');
  deepEqual(get(obj, 'foo'), { a: true, b: true, c: true, d: true, e: true, f: true }, 'get foo');
  deepEqual(get(obj, 'bar'), { a: true, l: true, e: true, x: true }, 'get bar');
});
开发者ID:GCheung55,项目名称:glimmer,代码行数:21,代码来源:ember-metal-merged-properties-test.ts

示例6: function

QUnit.test('overriding toString', function() {
  let MixinA = Mixin.create({
    toString() { return 'FOO'; }
  });

  let obj = {};
  MixinA.apply(obj);
  equal(obj.toString(), 'FOO', 'should override toString w/o error');

  obj = {};
  mixin(obj, { toString() { return 'FOO'; } });
  equal(obj.toString(), 'FOO', 'should override toString w/o error');
});
开发者ID:GCheung55,项目名称:glimmer,代码行数:13,代码来源:ember-mixin-method-test.ts


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