本文整理汇总了TypeScript中glimmer-object.alias函数的典型用法代码示例。如果您正苦于以下问题:TypeScript alias函数的具体用法?TypeScript alias怎么用?TypeScript alias使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了alias函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
QUnit.test('old dependent keys should not trigger property changes', function() {
let obj1 = Object.create(null);
defineProperty(obj1, 'foo', null);
defineProperty(obj1, 'bar', alias('foo'));
defineProperty(obj1, 'baz', alias('foo'));
defineProperty(obj1, 'baz', alias('bar')); // redefine baz
let ref = observe(obj1, 'baz');
equal(ref.value(), null, "The value starts out null");
set(obj1, 'foo', 'FOO');
equal(ref.value(), 'FOO', "And it sees the new value");
set(obj1, 'foo', 'OOF');
});
示例2: function
QUnit.test('can iterate over a list of computed properties for a class', function() {
let MyClass = EmberObject.extend({
foo: computed(function() {}),
fooDidChange: observer('foo', function() {}),
bar: computed(function() {}),
qux: alias('foo')
});
let SubClass = MyClass.extend({
baz: computed(function() {})
});
SubClass.reopen({
bat: computed(function() {}).meta({ iAmBat: true })
});
let list = [];
MyClass.eachComputedProperty(function(name) {
list.push(name);
});
deepEqual(list.sort(), ['bar', 'foo', 'qux'], 'watched and unwatched computed properties are iterated');
list = [];
SubClass.eachComputedProperty(function(name, meta) {
list.push(name);
if (name === 'bat') {
deepEqual(meta, { iAmBat: true });
} else {
deepEqual(meta, {});
}
});
deepEqual(list.sort(), ['bar', 'bat', 'baz', 'foo', 'qux'], 'all inherited properties are included');
});
示例3: defineProperty
assert.throws(function() {
defineProperty(obj, 'bar', alias('bar'));
}, /Setting alias \'bar\' on self/);