Stale-by-Design Pattern Uses Single Status Field to Manage Cached Data Freshness
A software design pattern called 'Stale by Design' proposes managing cached app data using a single status field with five possible states: idle, stale, loading, fresh, or error. The approach separates two distinct responsibilities — marking data as stale can be done cheaply by any part of the app, while actually reloading data only happens when a component actively needs it. This avoids two common pitfalls: refetching on every possible change, or manually wiring reload calls across multiple unrelated files. In the demonstrated implementation using NgRx, actions like switchTeam or renameMemberSuccess trigger an invalidation effect without those actions needing any direct knowledge of the boards data. A shared observable stream ensures that no matter how many components are watching, a single stale transition triggers exactly one reload request.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in