Skip to main content
Jonathan Andrei
Back to all posts
Jan. 2022 - Apr. 20223 min read

Why I Used the Observer Pattern for a Tiny Fitness App

The observer pattern gets taught as a textbook example. Building a real-time fitness chart that updates from multiple sources made it earn its keep.

JavaScriptChartsDesign Patterns

Charts that update from a single source can get away with pull-based updates. Once you have two — workouts and heart-rate samples landing on different cadences — you either invent the observer pattern badly, or use it.

The thing that surprised me wasn't the pattern. It was how much cleaner the test surface got when the chart didn't know where its data was coming from — only that something it was watching had changed.

Related project

Dynamic Graphs Displaying Fitness Data

View the project