本文整理汇总了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)
})