0

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 ?

Bergi
  • 630,263
  • 148
  • 957
  • 1,375
civiltomain
  • 1,136
  • 1
  • 9
  • 27
  • The question is very difficult to understand. Can you provide a specific example? – joews Sep 17 '14 at 18:43
  • I wonder what you mean by "synchronism". Notice that promises are still (or should I say: prominently, explicitly?) asynchronous. – Bergi Sep 17 '14 at 19:42
  • @Bergi Promises/A+ implementations are explicitly asynchronous, but jQuery's Deferred, (the most widely used Promise API?) does not guarantee asynchronicity. – joews Sep 17 '14 at 21:24
  • @joews: Sure, but still they're typically used in an async context. – Bergi Sep 18 '14 at 09:38

1 Answers1

1

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.

Community
  • 1
  • 1
Bergi
  • 630,263
  • 148
  • 957
  • 1,375