本文整理匯總了TypeScript中@glimmer/object.alias函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript alias函數的具體用法?TypeScript alias怎麽用?TypeScript alias使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了alias函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: defineProperty
QUnit.test('old dependent keys should not trigger property changes', assert => {
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');
assert.equal(ref.value(), null, "The value starts out null");
set(obj1, 'foo', 'FOO');
assert.equal(ref.value(), 'FOO', "And it sees the new value");
set(obj1, 'foo', 'OOF');
});
示例2: observe
QUnit.test('immediately sets up dependencies if already being watched', assert => {
let ref = observe(obj, 'bar');
defineProperty(obj, 'bar', alias('foo.faz'));
set(obj, 'foo.faz', 'BAR');
assert.equal(ref.value(), 'BAR');
// QUnit.assert.equal(count, 1);
});