Member-only story

Push-based Architectures with RxJS

Thomas Burleson
9 min readMay 24, 2019

… all this time you have been coding wrong!

Before I can show you HOW to implement Push-Based architectures, I need to first describe WHY Pull-Based solutions are flawed… and WHY Push-Based systems are better.

Most developers learn to program, code, and build software architectures using traditional Pull-based approaches. In the world of web applications and asynchronous, rich user experiences this approach is flawed, rampant with myriad problems, and is fundamentally wrong.

Traditional Pull-Based Solutions

With Pull-based architecture, the views will explicitly call service methods to force-reload (aka ‘pull’) the data. This is the traditional approach employed by most developers.

Consider the simple function call findAllUsers() used to retrieve a list of users… here the code is pulling data to a view. If the user list subsequently changes, views (or services) must issue another pull request with findAllUsers(). But how do the views know when to issue another request?

Notice I have not stated whether the data is currently in-memory or must be retrieved from the server…

Thomas Burleson
Thomas Burleson

Written by Thomas Burleson

Solutions architect expert in NextJS, React and Angular solutions. Formerly a Principal Architect @ Nrwl.io, Team Lead for Angular, Google.

Responses (18)

Write a response

Excellent article Thomas Burleson. I have one question though.
Why do you classify event listeners as pull based? They just subscribe to an event (like you would subscribe to an observable) and “react” to events. They seem to behave like a push based system to me.

3

Hi Thomas, congratulations for the amazing article. Talking about errors, in a pull architecture we would use a try catch to show a “try again” button if the data is not received (in case of internet connection error or some api error). This is easy…

2

To detect changes, comparisons simply use === to determine if the data reference is a new instance. And when changes are detected, then the changed data is re-delivered through the stre...

This also describes how OnPush strategy works in components in Angular

1