civiltomain
civiltomain

Reputation: 1166

Syncronism, even with Promises, needs some eventlistener or not?

That is, If you want to use promise with async procceses, you must have 'onload' or similar listeners to can execute the next function (resolve or whatever).

Is that true or false ?

Upvotes: 0

Views: 98

Answers (1)

Bergi
Bergi

Reputation: 665130

Yes, every asynchronous process must allow you to attach a listener so that it can signal you[1] that is has finished. Without these, you wouldn't know when to resolve your promise. Promises are built atop callbacks.

Of course there's also the possibility that some asynchronous processes return native promises and don't let you attach any listeners explicitly, but this is not yet implemented in the wild.

[1]: Of course, there are some APIs that don't support listeners, but just change some value and expect you to observe this change. Such an API can be polled, but is very inconvenient to use.

Upvotes: 1

Related Questions