O'Reilly logo

TypeScript: Modern JavaScript Development by Ivo Gabe de Wolff, Vilic Vane, Remo H. Jansen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Asynchronous programming in TypeScript

Now that we have seen how to work with functions, we will explore how we can use them, together with some native objects, to write asynchronous applications.

Callbacks and higher-order functions

In TypeScript, functions can be passed as arguments to another function. The function passed to another as an argument is known as a callback. Functions can also be returned by another function. The functions that accept functions as parameters (callbacks) or return functions as an argument are known as higher-order functions. Callbacks are usually anonymous functions.

var foo = function() { // callback console.log('foo'); } function bar(cb : () => void) { // higher order function console.log('bar'); cb(); } bar(foo); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required