本文整理汇总了TypeScript中spica/cancellation.Cancellation类的典型用法代码示例。如果您正苦于以下问题:TypeScript Cancellation类的具体用法?TypeScript Cancellation怎么用?TypeScript Cancellation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Cancellation类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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());
});
开发者ID:falsandtru,项目名称:pjax-api,代码行数:34,代码来源:script.test.ts
示例2: Error
.fmap(async config => {
void event.original.preventDefault();
void process.cast('', new Error(`Aborted.`));
const cancellation = new Cancellation<Error>();
const kill = process.register('', e => {
void kill();
void cancellation.cancel(e);
return new Promise<never>(() => undefined);
}, undefined);
const [scripts] = await env;
window.history.scrollRestoration = 'manual';
//void progressbar(config.progressbar);
return router(config, event, { process: cancellation, scripts }, io)
.then(m => m
.fmap(async ([ss, p]) => (
void kill(),
void docurl.sync(),
void ss
.filter(s => s.hasAttribute('src'))
.forEach(s =>
void scripts.add(new URL(standardize(s.src)).reference)),
void (await p)
.filter(s => s.hasAttribute('src'))
.forEach(s =>
void scripts.add(new URL(standardize(s.src)).reference))))
.extract())
.catch(reason => (
void kill(),
void docurl.sync(),
window.history.scrollRestoration = 'auto',
!cancellation.canceled || reason instanceof FatalError
? void config.fallback(currentTargets.get(event.original) as RouterEventSource, reason)
: undefined));
})
开发者ID:falsandtru,项目名称:pjax-api,代码行数:34,代码来源:router.ts
示例3: 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());
});
开发者ID:falsandtru,项目名称:pjax-api,代码行数:17,代码来源:xhr.test.ts
示例4: kill
const kill = process.register('', e => {
void kill();
void cancellation.cancel(e);
return new Promise<never>(() => undefined);
}, undefined);
开发者ID:falsandtru,项目名称:pjax-api,代码行数:5,代码来源:router.ts
注:本文中的spica/cancellation.Cancellation类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论