本文整理汇总了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();
}