Skip to content

docs: add async data ADT section#319

Open
landeqiming666 wants to merge 1 commit into
piotrwitek:masterfrom
landeqiming666:docs-async-data-states
Open

docs: add async data ADT section#319
landeqiming666 wants to merge 1 commit into
piotrwitek:masterfrom
landeqiming666:docs-async-data-states

Conversation

@landeqiming666

@landeqiming666 landeqiming666 commented Jun 12, 2026

Copy link
Copy Markdown

Summary

  • Add a source-first section about modelling async data states with algebraic data types.
  • Regenerate README.md from README_SOURCE.md so the generated docs stay in sync.
  • Cover loading, failure, and success states with small TypeScript examples.

Validation

  • npm ci --ignore-scripts
  • npm run ci-check
  • git diff --check HEAD~1..HEAD

Relates to #40.


IssueHunt Summary

Referenced issues

This pull request has been submitted to:


@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread README.md
Comment on lines +1576 to +1578
function assertNever(value: never): never {
throw new Error(`Unhandled remote data case: ${JSON.stringify(value)}`);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
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));
}

Comment thread README_SOURCE.md
Comment on lines +697 to +699
function assertNever(value: never): never {
throw new Error(`Unhandled remote data case: ${JSON.stringify(value)}`);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
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));
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant