LiveLoveApp logo

What Does it Solve?

What does it solve?

According to the documentation:

RxJS is a library for composing asynchronous and event-based programs by using observable sequences.

At the core, RxJS enables JavaScript developers to build applications using reactive functional programming.

What is Reactive Programming?

Reactive programming, defined by Wikipedia:

In computing, reactive programming is a declarative programming paradigm concerned with data streams and the propagation of change.

Reactive programming uses a push strategy. This is distinctly different than a pull strategy.

Let's look at both.

Pull Strategies

In a pull-based strategy, the production of values occurs when the consumer requests a value.

In its simplest form, a function is pull-based. The function only does its thing when invoked.

Push Strategy

In a push strategy, the production of values occurs when the producer determines.

Today, we rely on the use of a Promise for push-based strategies. When the Promise resolves, the consumer receives the value produced.

A Promise is different from a function in that the producer determines when the value is produced, and thus provided to the consumers.

Observables are "push" functions

We can think of an Observable, the core primitive provided by RxJS that enables reactive programming, to be a "push" based function with zero arguments that can produce 0 or more (infinite) values.