本文整理匯總了TypeScript中@dojo/core/async/Task.reject函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript reject函數的具體用法?TypeScript reject怎麽用?TypeScript reject使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了reject函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: _handleError
protected _handleError(error: Error) {
// Make the _ready task a reject to reject future _sendData calls
this._ready = Task.reject(error);
// Reject any open sends
Object.keys(this._sendQueue)
.filter(id => this._sendQueue[id] != null)
.forEach(id => {
this._sendQueue[id]!.reject(error);
this._sendQueue[id] = undefined;
});
}
示例2: _sendData
protected _sendData(name: string, data: any) {
try {
const id = String(this._sequence++);
const sessionId = this.sessionId;
const message: Message = { id, sessionId, name, data };
return this._ready.then(() => new Task<void>((resolve, reject) => {
this._socket.send(JSON.stringify(message));
const timer = setTimeout(() => {
reject(new Error('Send timed out'));
}, this.timeout);
this._sendQueue[id] = () => {
clearTimeout(timer);
resolve();
};
}));
}
catch (error) {
return Task.reject<void>(error);
}
}