本文整理汇总了TypeScript中spica/cancellation.Cancellation.cancel方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Cancellation.cancel方法的具体用法?TypeScript Cancellation.cancel怎么用?TypeScript Cancellation.cancel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spica/cancellation.Cancellation
的用法示例。
在下文中一共展示了Cancellation.cancel方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('cancel', done => {
let cnt = 0;
const cancellation = new Cancellation<Error>();
script(
{
src: parse(html('head', [html('script', { class: 'test' })]).outerHTML).extract(),
dst: parse('').extract()
},
new Set([]),
{
ignore: '',
reload: '',
logger: 'head'
},
1e3,
cancellation,
{
fetch: async script => {
assert(cnt === 0 && ++cnt);
assert(script.className === 'test');
return Right(tuple([script, '']));
},
evaluate: script => {
assert(++cnt === NaN);
return Left(AtomicPromise.resolve(Right(script)));
},
})
.then(m => {
assert(cnt === 1 && ++cnt);
assert(m.extract(e => e) instanceof Error);
done();
});
cancellation.cancel(new Error());
});
示例2: it
it('cancel', done => {
const cancellation = new Cancellation<Error>();
xhr(
RouterEventMethod.GET,
new URL(standardize('')),
new Headers(),
null,
0,
p => p,
() => '',
cancellation)
.then(m => m.extract(err => {
assert(err instanceof Error);
done();
}));
cancellation.cancel(new Error());
});
示例3: kill
const kill = process.register('', e => {
void kill();
void cancellation.cancel(e);
return new Promise<never>(() => undefined);
}, undefined);