I've got troubles with awaiting Promise.all()
, it never continues after that. I've got helper function for creating cancelable promises:
create(promise) {
let hasCanceled_ = false
const wrappedPromise = new Promise((resolve, reject) => {
promise.then(
val => (hasCanceled_ ? reject({ isCanceled: true }) : resolve(val)),
error => (hasCanceled_ ? reject({ isCanceled: true }) : reject(error))
)
})
const cancelablePromise = {
promise: wrappedPromise,
cancel() {
hasCanceled_ = true
}
}
return cancelablePromise
}
then I created promises like following way:
const timelinePromise = this.pendingPromises.create(
this.fetchWholeTimeline(false)
)
const confJobsPromise = this.pendingPromises.create(
this.fetchWorkspaceJobConfigurationJobs(false)
)
and at least I'm executing this piece of code:
const [timelineResponse, confJobsResponse] = await Promise.all(
timelinePromise.promise,
confJobsPromise.promise
)
console.log(timelineResponse)
console.log(confJobsResponse)
The console.logs
are never executed... What I'm doing wrong here?