flâneur — a map of the web's best reading

Reading 15: Promises

web.mit.edu · 6,451 words · saved by 2 readers

We start at the highest level, with the promise abstraction, and the await operator and async function declaration that allow concurrent computations to happen in TypeScript in a way that closely resembles familiar synchronous programming. Then we will dig below the covers to understand more about what is really happening with Promise, await, and async. A promise represents a concurrent computation that has been started but might still be unfinished, whose result may not be ready yet. The name comes from the notion that it is a promise to finish the computation and provide a result sometime in the future. The Promise type in TypeScript is generic: a Promise<T> represents a concurrent computation that at some point should produce a value of type T. Here are examples of concurrent computations using promises. (Some of these are actual functions provided by Node packages; others don’t currently exist as library functions but could be readily implemented.) Importantly, each of these functi

Reading 15: Promises Reading 15: Promises Software in 6.102 Safe from bugs Easy to understand Ready for change Correct today and correct in the unknown future. Communicating clearly with future programmers, including future you. Designed to accommodate change without rewriting. Objectives This reading discusses concurrent computation using promises . We start at the highest level, with the promise abstraction, and the await operator and async function declaration that allow concurrent computations to happen in TypeScript in a way that closely resembles familiar synchronous programming. Then we

Explore this link on the map →

saved by

related reading