本文整理汇总了TypeScript中backburner.schedule函数的典型用法代码示例。如果您正苦于以下问题:TypeScript schedule函数的具体用法?TypeScript schedule怎么用?TypeScript schedule使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了schedule函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
QUnit.test('schedule - DEBUG flag enables stack tagging', function(assert) {
let bb = new Backburner(['one']);
bb.schedule('one', () => {});
if (!bb.currentInstance) {
throw new Error('bb has no instance');
}
assert.ok(bb.currentInstance && !bb.currentInstance.queues.one.stackFor(0), 'No stack is recorded');
bb.DEBUG = true;
bb.schedule('one', () => {});
if (new Error().stack) { // workaround for CLI runner :(
assert.expect(4);
let stack = bb.currentInstance && bb.currentInstance.queues.one.stackFor(1);
assert.ok(typeof stack === 'string', 'A stack is recorded');
let onError = function(error, errorRecordedForStack) {
assert.ok(errorRecordedForStack, 'errorRecordedForStack passed to error function');
assert.ok(errorRecordedForStack.stack, 'stack is recorded');
};
bb = new Backburner(['errors'], { onError });
bb.DEBUG = true;
bb.run(() => {
bb.schedule('errors', () => {
throw new Error('message!');
});
});
}
});
示例2: resetError
bb.run(function() {
bb.schedule('one', target1, method, arg1);
bb.schedule('two', target2, method, arg1, arg2);
debugInfo = bb.getDebugInfo();
resetError();
assert.deepEqual(debugInfo.instanceStack,
[
{
one: [
{
args: [arg1],
method,
stack: oneStack,
target: target1
}
],
two: [
{
args: [arg1, arg2],
method,
stack: twoStack,
target: target2
}
]
}
]
, 'debugInfo is output');
});
示例3:
bb.run(() => {
bb.schedule('render', method);
bb.schedule('afterRender', method);
debugInfo = bb.currentInstance && bb.currentInstance._getDebugInfo(bb.DEBUG);
assert.deepEqual(debugInfo, {
render: [
{
target: null,
method,
args: undefined,
stack: renderStack
}
],
afterRender: [
{
target: null,
method,
args: undefined,
stack: afterRenderStack
}
]
});
});
示例4: increment
function increment() {
if (++count < 3) {
bb.schedule('one', increment);
}
if (count === 3) {
bb.schedule('one', increment);
}
}
示例5:
bb.run(() => {
items.push(0);
bb.schedule('one', () => items.push(4));
bb.join(() => {
items.push(1);
bb.schedule('one', () => items.push(5));
items.push(2);
});
bb.schedule('one', () => items.push(6));
items.push(3);
});
示例6: function
QUnit.test('customized flushing - precedence is rechecked upon each flush', function(assert) {
assert.step('start');
let deferredFlush;
let bb = new Backburner(
[
'zomg',
'render',
'afterRender'
],
{
flush(queueName, flush) {
if (deferredFlush === undefined && queueName === 'render') {
deferredFlush = flush;
} else {
flush();
}
}
}
);
bb.schedule('zomg', null, () => {
assert.step('running zomg');
});
bb.schedule('render', null, () => {
assert.step('running render');
});
bb.schedule('afterRender', null, () => {
assert.step('running afterRender');
});
return escapeCurrentMicrotaskQueue()
.then(() => {
bb.schedule('zomg', null, () => {
assert.step('running zomg 2');
});
deferredFlush();
})
.then(escapeCurrentMicrotaskQueue)
.then(() => {
assert.verifySteps([
'start',
'running zomg',
'running zomg 2',
'running render',
'running afterRender',
]);
});
});
示例7: function
bb.run(function() {
assert.equal(step++, 0, '0');
bb.schedule('two', null, function() {
assert.equal(step++, 1, '1');
bb.schedule('one', null, function() {
assert.equal(step++, 3, '3');
});
});
bb.schedule('two', null, function() {
assert.equal(step++, 2, '2');
});
});
示例8:
return Promise.resolve().then(() => {
actual.push('third');
bb.schedule('actions', () => {
actual.push('action3');
});
});