本文整理汇总了TypeScript中@phosphor/coreutils.PromiseDelegate.reject方法的典型用法代码示例。如果您正苦于以下问题:TypeScript PromiseDelegate.reject方法的具体用法?TypeScript PromiseDelegate.reject怎么用?TypeScript PromiseDelegate.reject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@phosphor/coreutils.PromiseDelegate
的用法示例。
在下文中一共展示了PromiseDelegate.reject方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should reject the underlying promise', done => {
let delegate = new PromiseDelegate<number>();
delegate.promise.catch(reason => {
expect(reason).to.equal('foo');
done();
});
delegate.reject('foo');
});
示例2: expect
tester.onMessage(msg => {
try {
expect(msg.header.msg_id).to.be(msgId);
} catch (e) {
done.reject(e);
throw e;
}
done.resolve(null);
});
示例3: TextDecoder
tester.onMessage(msg => {
try {
let decoder = new TextDecoder('utf8');
let item = msg.buffers[0] as DataView;
expect(decoder.decode(item)).to.be('hello');
} catch (e) {
done.reject(e);
throw e;
}
done.resolve(null);
});
示例4: catch
debouncer = window.setTimeout(async () => {
const data = await db.toJSON();
try {
await workspaces.save(id, { data, metadata });
if (conflated) {
conflated.resolve(undefined);
}
} catch (error) {
if (conflated) {
conflated.reject(error);
}
}
conflated = null;
}, timeout);
示例5: catch
debouncer = window.setTimeout(async () => {
// Prevent a race condition between the timeout and saving.
if (!conflated) {
return;
}
const data = await state.toJSON();
try {
await workspaces.save(id, { data, metadata });
conflated.resolve(undefined);
} catch (error) {
conflated.reject(error);
}
conflated = null;
}, timeout);
示例6: it
it('should resolve to true even if the promise is rejected', async () => {
const p = new PromiseDelegate<number>();
expect(await isFulfilled(p.promise)).to.equal(false);
p.reject(new Error('my error'));
expect(await isFulfilled(p.promise)).to.equal(true);
});
示例7:
.catch(reason => {
conflated.reject(reason);
conflated = null;
});