Search⌘ K
AI Features

Promise vs. Observables with AJAX

Explore the distinctions between promises and observables when handling AJAX requests in RxJS. Learn how observables enable multiple values, enhanced error handling, and retries to improve user experience, especially in unstable network conditions. Understand how to integrate promises with observables and why maintaining a consistent abstraction benefits your codebase.

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 ...