Member-only story

How to dataflow merge on Observable

Tom Larkworthy
3 min readNov 5, 2021

In this series, I will explore programming techniques for the notebook platform Observable. Today I am looking at how to merge multiple reactive Dataflow streams into a single stream. This article assumes you are familiar with Observable’s non-linear reactive program flow already.

A common situation is this: you have a notebook that performs some useful task, and you want to offer a few different ways to start that task. For example, starting something based on configuration obtained from either URL parameters, local storage, or a manual UI. It’s a little trickier than you would hope because, if each of these methods is in their own cell [1], then we have multiple distinct data flow pathways converging into a single flow.

[1] and they probably should be because of separation-of-concerns

The core difficulty is if there is no data in a source, its dataflow won’t tick, so if the business logic depends on all the input sources, the business logic will not tick either. So this pattern described here will joins the business logic to the sources a different way so that if any of them tick, the business logic will tick too.

In ReactiveX terms, Observable’s dataflow is a combineLatest across cell streams, but we want a merge.

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Tom Larkworthy
Tom Larkworthy

Written by Tom Larkworthy

Observablehq/Cloud consultant. Developing webcode.run to serverless to Observablehq. Ex-Firebase, Ex-Google Cloud.

No responses yet

Write a response