The RxJS Backbone

Let's create the RxJS backbone of our game that allows us to easily see and change the order things are rendered in.

First step down! Now, on to interactivity and animations.

The RxJS backbone

For a game to work, every frame, we need to go through every item in the game, make any changes to the item’s state, and then render everything on the page.

Custom operators and tap operator in games

RxJS lets us declaratively state each step through custom operators and tap.

Our custom operators take in the entire observable, so each item has the complete freedom to do whatever it needs to along the way through the entire RxJS API. Once the updates are done, tap lets us call the render functions safely, ensuring that errant code won’t accidentally update the state.

Get hands-on with 1400+ tech skills courses.