use Promises for tasks
See original GitHub issueWe’re writing majority of code using async/await these days. So our first thought was to use it for kue-tasks too. Something like this:
queue.process('hello', async (job) => {
let tmpResult = await someLongBoringOperation(job.data.name);
await otherLongOperation(tmpResult, job.data.planet);
});
That doesn’t work as kue doesn’t distinguish promises from regular functions. Workarounds are mentioned in Readme, but they hurt elegance of app code.
Is there a chance that kue will have “native” support for promises?
The only complication I see is optional workerCtx
param. Otherwise, the code should be trivial
Issue Analytics
- State:
- Created 8 years ago
- Reactions:12
- Comments:17 (4 by maintainers)
Top Results From Across the Web
Using promises - JavaScript - MDN Web Docs
A Promise is an object representing the eventual completion or failure of an asynchronous operation. Since most people are consumers of already- ...
Read more >How to Learn JavaScript Promises and Async/Await in 20 ...
In JavaScript, we can create a new Promise with new Promise() , which takes in a function as an argument: (resolve, reject) =>...
Read more >JavaScript promises, mastering the asynchronous - CodinGame
JavaScript promises, mastering the asynchronous · The function job must return a promise object (you are in a NodeJS environment, you can use...
Read more >25. Promises for asynchronous programming - Exploring JS
Promises are an alternative to callbacks for delivering the results of an asynchronous computation. They require more effort from implementors of asynchronous ...
Read more >Promise - The Modern JavaScript Tutorial
A Promise object serves as a link between the executor (the “producing code” or “singer”) and the consuming functions (the “fans”), which will ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Why not standard es6 promises? I personally find it slightly annoying when third party modules use their own promise implementation.
@olalonde http://programmers.stackexchange.com/questions/278778/why-are-native-es6-promises-slower-and-more-memory-intensive-than-bluebird
@behrad +1 for bluebird