Introduction to Concurrent Programs

Learn the concept of concurrency and pipelines.

Concurrency

Concurrency is the art of doing several things at the same time, correctly and efficiently. To accomplish this, we structure our programs to take advantage of time so that tasks run together in the most efficient way.

Examples of everyday concurrency in applications include keeping the user interface responsive while other activities are taking place, and processing hundreds of customers’ orders efficiently.

In this chapter, we’ll explore concurrency and pure functions in RxJS by making a shoot-’em-up spaceship game for the browser. We’ll first introduce the Observable pipeline.

Note: An Observable pipeline is a technique that is used to chain Observable operators and pass state between them.

Then, we’ll learn how to use the pipeline to build programs without relying on external state or side effects, by encapsulating all our logic and state inside the Observables themselves. Video games are computer programs that need to keep a lot of states, but we’ll write our game with no external state whatsoever, using the power of the Observable pipeline and some great RxJS operators.

Purity and the Observable pipeline

An Observable pipeline is a group of operators chained together, where each one takes an Observable as input and returns an Observable as output.

We’ve been using pipelines in this course. They are ubiquitous when programming with RxJS. Here’s a simple one:

Get hands-on with 1200+ tech skills courses.