docs: add async data ADT section#319
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds a new section to both README.md and README_SOURCE.md titled "Modelling async data with ADT", which explains how to model asynchronous reducer state using discriminated unions (Algebraic Data Types) instead of multiple boolean flags and nullable fields. The feedback suggests making the assertNever helper function more generic and reusable by changing its hardcoded error message from "Unhandled remote data case" to a more general "Unhandled case".
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| function assertNever(value: never): never { | ||
| throw new Error(`Unhandled remote data case: ${JSON.stringify(value)}`); | ||
| } |
There was a problem hiding this comment.
The assertNever helper is a generic TypeScript utility used to enforce exhaustiveness checks. Hardcoding the error message to 'Unhandled remote data case' makes it less reusable for other union types (such as actions, states, or action types) if readers copy-paste this helper into their projects. Making the error message generic improves its reusability.
| function assertNever(value: never): never { | |
| throw new Error(`Unhandled remote data case: ${JSON.stringify(value)}`); | |
| } | |
| function assertNever(value: never): never { | |
| throw new Error('Unhandled case: ' + JSON.stringify(value)); | |
| } |
| function assertNever(value: never): never { | ||
| throw new Error(`Unhandled remote data case: ${JSON.stringify(value)}`); | ||
| } |
There was a problem hiding this comment.
The assertNever helper is a generic TypeScript utility used to enforce exhaustiveness checks. Hardcoding the error message to 'Unhandled remote data case' makes it less reusable for other union types (such as actions, states, or action types) if readers copy-paste this helper into their projects. Making the error message generic improves its reusability.
| function assertNever(value: never): never { | |
| throw new Error(`Unhandled remote data case: ${JSON.stringify(value)}`); | |
| } | |
| function assertNever(value: never): never { | |
| throw new Error('Unhandled case: ' + JSON.stringify(value)); | |
| } |
Summary
README.mdfromREADME_SOURCE.mdso the generated docs stay in sync.Validation
npm ci --ignore-scriptsnpm run ci-checkgit diff --check HEAD~1..HEADRelates to #40.
IssueHunt Summary
Referenced issues
This pull request has been submitted to: