Tag: promises
Promises are awesome, but it was always a bit annoying how you had to roll your own solution if you wanted to resolve a promise from outside its callback. Meet Promise.withResolvers()
, which solves that problem.
In this article I'll look at a few approaches to running a sequence of promises - in my case representing a number of login attempts to different instances of a back-end system - until one of them succeeds.
JavaScript modules are a great way to manage and load code dependencies. But static imports can be problematic. Wouldn't it be cool if there was a way to import dynamically and conditionally? Well, there is...
Meet Promise.any()
, which is supported by the just-released Firefox 79. It's like Promise.race()
, except it listens only for the first promise to be fulfilled, not merely resolved either way.
When the JavaScript Promises specification was released, one of the first questions that got asked (and is still asked) was: but how do I resolve them from outside, a la jQuery deferred objects? That's not how they're intended to work, but it is possible.
In the first article in this series we looked at the history and run-up to the game-changing async/await
combo. In this article we'll get down to using it and seeing precisely how it works.
ECMAScript 2016's async/await
combo really was a game-changer when it comes to writing shallow, synchronous-looking code that hides away asynchronous operations, and they really took promises to a new level. Let's meet them!
Rounding off this three-part series on JavaScript promises, in this article we'll look at promise events, combining promises with ECMAScript 2017's async/await
combo, plus some of the standard APIs that use or depend on promises.
In this second of three articles on JavaScript promises we'll be digging a little deeper, this time looking at error handling with promises, promise methods such as Promise.resolve()
and how promises can handle concurrent requests.
Promises a great way to write shallow, readable code that looks synchronous but actually hides away asynchronous operations. In this first of three articles I'll be showing you how they work, and what problem they solve.
In this, the second part in my three-part guide to JavaScript generators, we'll see how generator functions lend themselves particularly to asynchronous situations - but hiding that asynchronicity away behind synchronous-looking code flows.