Skip to main content

Questions tagged [promises]

A promise is essentially an API that returns a future value, or a way to manage callback functions. More technically, a promise is a programming pattern that helps invoking a mechanism that is going to be asynchronous in nature.

-2votes
1answer
106views

Creating a promise based API, from a message based API

I'm building some software that behind the scenes needs to communicate with hardware via a "message" API, over a named pipe. For example, I can send this message: <?xml version="1.0&...
i.brod's user avatar
0votes
1answer
110views

Organizing Parallel Arrays of Promises / Async tasks

I'm struggling a bit for a preferred way to organize a sequence of asynchronous tasks that can be applied in parallel. Say, you are parsing data from many files. In my case I'm using javascript and ...
user949300's user avatar
7votes
2answers
4kviews

How do JavaScript engines convert async/await to promises under the hood?

I'm curious how the async/await syntax is converted to Promises. Maybe I'm just not thinking about it properly, but I don't know how this code would be converted to a Promise: async function myFunc(...
dx_over_dt's user avatar
0votes
0answers
69views

Streaming Promises in NodeJS

Imagine a typical HTTP service that does async db queries. If HTTP requests are received more quickly than the db can complete queries (such as because the db disk or network is slow), the Promises ...
squarewav's user avatar
-1votes
1answer
143views

Does avoiding Promises and Async leads to clean code?

While applying for a job interview I found this line in requirements. Experience with clean code writing practices like avoiding callback hell like promises, async Does this line make any sense ? ...
ZaidRehman's user avatar
0votes
3answers
391views

If callback function, promises and async/await patterns all can be used to achieve asynchronous behaviour then why don't we stick to one?

As far as I have seen then async/await, callbacks and promises are and can only be used to achieve asynchronous programming. Correct? So my questions are: 1) Is it correct that the former three is ...
CodingManiac's user avatar
-1votes
3answers
325views

Writing elegant promises in Node.js

I am having a real difficult time writing some clean code with a simple user registration/login manager. I am trying to stay out of nesting/callback hell, and am also not seeing any benefit in using ...
jozenbasin's user avatar
13votes
3answers
14kviews

How does JS Promises works being single threaded

Javascript is single threaded. What I understand from this is if JS i executing on line of code lets say a function. It cannot go to the next line unless that function has been removed from the stack. ...
user avatar
3votes
1answer
432views

What is the advantage of flattening dependent Promises

I've read that nesting Promise continuations is bad practice. For example, here. GetCustomer().then(customer => { ProcessCustomer(customer).then(processingResult => { console....
Tom Bowers's user avatar
0votes
3answers
4kviews

Which is more readable: early returns, or conditionals? [duplicate]

I’m writing an asynchronous, Promise-returning function. In the processing I test some conditions, and if the conditions pass, the promise should be fulfilled (resolved), but if one fails, then the ...
chharvey's user avatar
1vote
1answer
1kviews

Angular2: Service architecture + error handling

I need support for Angular2 service architectures. I am quite familiar with Angular2 but I don't see the best way to implement services, error handling and their connection with the components. I'm ...
Gábor Imre's user avatar
0votes
1answer
88views

Framework accepts Promises or executor functions

When designing a framework API is it better to have something that accepts Promises or have executor functions and have the framework build the promises when needed. The Promise API is defined by ...
Archimedes Trajano's user avatar
1vote
2answers
2kviews

How to check for dangling Promises? (Bluebird.js)

I ran into an issue where I forgot to resolve my promise, leaving the remainder of the chain waiting (Forever). Thankfully in my case I was able to track down the issue in only 10 or so minutes, but ...
JasonS's user avatar
6votes
1answer
1kviews

What's the relation between Promises and Continuations

I think I understand what Promises are about, and I think I understand what continuations are about, but I still fail to see what their connection is. In what ways do Promises use Continuations. They ...
hgiesel's user avatar
5votes
2answers
382views

Is a promise-aware eventing system desirable?

I'm fully aware that Promises and eventing are both ways to do asynchronous programming, and you can choose either one for a given project. However, in practice, the code base I'm working with is ...
RonJRH's user avatar

153050per page
close