After having understood the basics of how the event loop works, it's time to explore the various different ways in which you can implement asynchronous operations in TypeScript. Each technique has its own unique style and it is important to understand the nitty-gritties of each. Careful and efficient implementation of the techniques can lead to writing a neat, bug-free, maintainable, and most importantly high performance code.

Let us begin with callbacks. We briefly touched upon the concept in the previous section. We had defined a callback as follows: Callback essentially is nothing but function F1 that is provided to a function F2 (most likely external), which is expected to be called when that function (F2) completes.

While it ...

Get TypeScript High Performance now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.