本文整理匯總了TypeScript中@glimmer/runtime.setDebuggerCallback函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript setDebuggerCallback函數的具體用法?TypeScript setDebuggerCallback怎麽用?TypeScript setDebuggerCallback使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了setDebuggerCallback函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: compile
QUnit.test('can get locals', assert => {
let template = compile(`{{#with foo as |bar|}}{{debugger}}{{/with}}`);
setDebuggerCallback((context: any, get: debugCallback) => {
assert.equal(get('foo'), 'woot');
assert.equal(get('bar'), 'woot');
assert.deepEqual(get('this'), context);
});
render(template, {
foo: 'woot'
});
});
示例2: setDebuggerCallback
@test "can get locals"() {
let expectedContext = {
foo: 'bar',
a: {
b: true
}
};
let callbackExecuted = 0;
setDebuggerCallback((context: any, get) => {
callbackExecuted++;
this.assert.equal(get('foo'), expectedContext.foo);
this.assert.equal(get('bar'), expectedContext.foo);
this.assert.deepEqual(get('this'), context);
});
this.render('{{#with foo as |bar|}}{{#if a.b}}true{{debugger}}{{else}}false{{debugger}}{{/if}}{{/with}}', expectedContext);
this.assert.equal(callbackExecuted, 1);
this.assertHTML('true');
this.assertStableRerender();
expectedContext = {
foo: 'baz',
a: {
b: false
}
};
this.rerender(expectedContext);
this.assert.equal(callbackExecuted, 2);
this.assertHTML('false');
this.assertStableNodes();
expectedContext = {
foo: 'bar',
a: {
b: true
}
};
this.rerender(expectedContext);
this.assert.equal(callbackExecuted, 3);
this.assertHTML('true');
this.assertStableNodes();
}