Skip to content

feat: add the Phase 2 React adapter with Turborepo - #2

Merged
matheuseabra merged 3 commits into
mainfrom
feat/p2-react-adapter
Sep 5, 2026
Merged

matheuseabra merged 3 commits into
mainfrom
feat/p2-react-adapter

Conversation

@matheuseabra

@matheuseabra matheuseabra commented Sep 5, 2026

Copy link
Copy Markdown
Owner

Summary

Implements the Phase 2 framework adapter tasks in a separate @wthw7/effect-query-react workspace package. React stays out of the core manifest.

  • Add createQueryHooks(runtime) with typed runtime requirements, useQuery(definition, ...args), and useMutation(definition). Query fibers cancel on key change/unmount and handle StrictMode replay; mutation pending state covers concurrent calls and core onSuccess handlers.
  • Add an independent React test suite, compile-time requirement checks, a framework README example, and root/CI integration. Existing core coverage thresholds and cache semantics are unchanged.
  • Use pnpm workspaces with Turborepo to orchestrate both packages' checks, build core before adapter tasks, cache build/coverage artifacts, and reuse the local task cache in CI. Core stays at the repository root as registered Turbo root tasks; no source relocation or runtime behavior changes are needed.
  • Prepare both manifests for 0.3.0-beta.0. The release workflow packs workspace dependencies into registry versions and publishes core before the adapter.

API and cache semantics

Query errors are Effect Cause<E | KeyHashError> values. Mutations resolve Promise<Exit<A, E | E2>>, preserving failure, defect, and interruption outcomes. The application owns runtime disposal.

Hooks expose fetch snapshots, not live cache subscriptions: background revalidation, manual writes, and invalidation do not automatically rerender mounted consumers. Core winner/joiner cancellation remains unchanged, including interruption of surviving joiners when the winning observer unmounts. These boundaries are documented in the spec and adapter README.

Publishing is still pending and is not performed by this PR. Configure npm Trusted Publishing for the new adapter before releasing; the Phase 2 publish gate remains open.

Test plan

  • pnpm install --frozen-lockfile

  • pnpm check --force: 30 core tests and 16 adapter tests; both packages retain 100% line/function coverage, plus typecheck, lint, and build.

  • Adapter tests cover mount/fresh-cache reads, key changes, unmount cancellation, StrictMode, typed errors/defects, custom hashes, shared requests, injected services, mutation concurrency, and success handlers.

  • Compile-time negative cases reject missing runtime services and incorrect hook arguments.

  • Quality budget and complexity checks pass; git diff --check passes.

  • Pack both packages and install the tarballs in a blank npm project; verify the adapter's workspace dependency becomes ^0.3.0-beta.0.

  • React 18.3.1 packed-package smoke: StrictMode fetch, mutation, key change, and unmount cancellation. Workspace suite runs with React 19.

  • Warm Turbo run hits all 8 task caches; moving build/coverage outputs aside and rerunning restores all artifacts from cache.

  • Cache probes: core source changes invalidate core and dependent adapter tasks, adapter-only source changes preserve all core hashes, shared lint configuration changes invalidate all tasks. Temporary probes were reverted.

  • Filtered adapter test run builds missing core outputs first, with cache bypassed.

@matheuseabra matheuseabra changed the title feat: add the Phase 2 React adapter feat: add the Phase 2 React adapter with Turborepo Sep 5, 2026
@matheuseabra
matheuseabra merged commit 827abfa into main Sep 5, 2026
1 check passed
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