(wrappedFunction)
| 62 | } |
| 63 | |
| 64 | wrapForegroundJob(wrappedFunction) { |
| 65 | const context = this |
| 66 | |
| 67 | return function() { |
| 68 | const jobId = context.startForegroundJob() |
| 69 | |
| 70 | return Promise.resolve(wrappedFunction.apply(this, arguments)) |
| 71 | .then(result => { |
| 72 | context.finishForegroundJob(jobId) |
| 73 | |
| 74 | return result |
| 75 | }) |
| 76 | .catch(error => { |
| 77 | context.finishForegroundJob(jobId) |
| 78 | |
| 79 | return Promise.reject(error) |
| 80 | }) |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | module.exports = new WorkQueue() |
no test coverage detected