Spaceship Reactive!
To show how we can keep an application pure, we’ll build a video game in which our hero fights endless hordes of enemy spaceships. We’ll make heavy use of Observable pipelines, and I’ll point out along the way when it might be tempting to store state outside the pipeline and how to avoid it.
Video games notoriously keep a lot of external state—scores, screen coordinates for the characters, timers, and so on. Our plan is to build the whole game without relying on a single external variable that keeps state.
In our game, the player will move the spaceship horizontally using the mouse, and will shoot by clicking the mouse or tapping the spacebar. Our game will have four main actors: the moving star field in the background, ...
Get Reactive Programming with RxJS now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.