© Raju Gandhi 2019
R. GandhiJavaScript Nexthttps://doi.org/10.1007/978-1-4842-5394-6_10

10. Avoiding Callbacks with Promises

Raju Gandhi1 
(1)
Columbus, OH, USA
 

Working with asynchronous operations is tedious. For the longest time we resorted to using callbacks which proved hard to get right especially when it came to state management and error propagation. We then elevated the abstraction, leveraging promises. However, those too came with their own set of problems—with different libraries having varying implementations, leaving us frustrated and looking for a sane way to grapple with asynchronous operations.

That changes now! JavaScript introduces promises in ES6 as a native API, elevating promises to be a first-class citizen in the language. In this ...

Get JavaScript Next: Your Complete Guide to the New Features Introduced in JavaScript, Starting from ES6 to ES9 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.