本文整理匯總了TypeScript中src/utils/Deferred.reject函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript reject函數的具體用法?TypeScript reject怎麽用?TypeScript reject使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了reject函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: async
const checkResult = async (
promise: Promise<V>,
deferred: Deferred,
promiseID: number
) => {
let result
let isOk = true
try {
result = await promise
} catch (error) {
result = error
isOk = false
}
if (promiseID !== id) {
deferred.reject(new CancellationError())
} else if (!isOk) {
deferred.reject(result)
} else {
deferred.resolve(result)
}
}
示例2: Error
const reject = () => {
let bodyError = null
try {
bodyError = JSON.parse(xhr.responseText).error
} catch {
if (xhr.responseText && xhr.responseText.trim() !== '') {
bodyError = xhr.responseText
}
}
const statusError = xhr.statusText
const fallbackError = 'failed to execute Flux query'
const error: XHRError = new Error(bodyError || statusError || fallbackError)
error.xhr = xhr
deferred.reject(error)
clearTimeout(interval)
}
示例3: CancellationError
const cancel = () => {
isCancelled = true
graph.forEach(node => node.cancel())
deferred.reject(new CancellationError())
}
示例4: clearTimeout
cancel: () => {
clearTimeout(interval)
xhr.abort()
deferred.reject(new CancellationError())
},
示例5: CancellationError
cancel: () => {
conn.cancel()
deferred.reject(new CancellationError())
},
示例6:
conn.stream.on('error', err => {
deferred.reject(err)
})