本文整理匯總了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/);