Concluding Operators

Understand what the final code of the spaceship game will look like.

We'll cover the following

Ideas for improvements

We already have some ideas for making the game even more exciting, but let me propose some improvements that will make the game better and sharpen our RxJS skills at the same time:

  • Add a second, or third, starfield that moves at a different speed to create a parallax effect. This could be done in several different ways. However, we will try to reuse the existing code and do it as declaratively as possible.

  • Make more unpredictable enemies by making them fire at random intervals, instead of the fixed one specified in ENEMY_SHOOTING_FREQ. We can also make them fire more quickly as the player’s score gets higher!

  • Allow the player to get more points by hitting several enemies in a short amount of time.

Wrapping up

We’ve built an entire game for the browser using only Observables and along the way, we’ve seen several convenient methods that can be used to handle concurrency and compose and transform Observables. This is one of the strengths of RxJS. There is always a method to help with the problem that we’re trying to tackle. Feel free to explore them in the RxJS documentation.

Reactive programming makes it easy for us to write concurrent programs. The Observable abstraction and the powerful RxJS methods make it natural for different parts of a program to interact efficiently. Programming without relying on an external state might take some getting used to, but it has enormous benefits. We can encapsulate entire behaviors in a single Observable pipeline, making our program more solid and reliable.

In the next few chapters, we’ll pick up where we left off with our earthquake visualizer application and add a Node.js server part that shows tweets related to the earthquakes. We’ll also improve its user interface to make it look like a real earthquake dashboard.

Get hands-on with 1200+ tech skills courses.