Skip to Main Content
Hands-On Functional Programming with TypeScript
book

Hands-On Functional Programming with TypeScript

by Remo H. Jansen
January 2019
Beginner content levelBeginner
210 pages
4h 47m
English
Packt Publishing
Content preview from Hands-On Functional Programming with TypeScript

Promises

After seeing how the use of callbacks can lead to some maintainability problems, we are now going to learn about promises and how they can be used to write better asynchronous code. The core idea behind promises is that a promise represents the result of an asynchronous operation. A promise must be in one of the following three states:

  • Pending: The initial state of a promise.
  • Fulfilled: Also known as resolved, this the state of a promise representing a successful operation. The terms fulfilled and resolved are both commonly used to refer to this state.
  • Rejected: The state of a promise representing a failed operation.

Once a promise is fulfilled or rejected, its state can never change again. Let's look at the basic syntax of a promise: ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Functional Programming in JavaScript

Functional Programming in JavaScript

Luis Atencio
TypeScript Quickly

TypeScript Quickly

Yakov Fain, Anton Moiseev
Functional Programming in Kotlin

Functional Programming in Kotlin

Runar Bjarnason, Paul Chiusano, Marco Vermeulen

Publisher Resources

ISBN: 9781788831437Supplemental Content