本文整理匯總了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;
});