當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。