AI Features

Promise vs. Observables with AJAX

Let's see the behavior of Promises and Observables with AJAX, and some useful constructors and operators like fromPromise, toPromise, retry, etc.

AJAX requests

A question that always comes up when discussing using observables to make AJAX requests is: “Why not promises?” As we learned in Creating Observables, a promise represents a single value delivered overtime where an observable represents multiple values.

An AJAX request is a single value.

Promises vs. observables

Promises are simpler in concept, but the real world always complicates things. Pretend you’re developing the mobile platform for a ridesharing app. Users will typically use ...