Skip to content

Add unified useSyncStatus hook - #103

Draft
KidkArolis wants to merge 3 commits into
masterfrom
codex/use-sync-status
Draft

Add unified useSyncStatus hook#103
KidkArolis wants to merge 3 commits into
masterfrom
codex/use-sync-status

Conversation

@KidkArolis

Copy link
Copy Markdown
Collaborator

What changed

  • add a canonical figbird.sync tracker and React useSyncStatus() hook
  • expose phase, pending/failed write counts, fetching query count, pending reconciliation count, and lastSyncedAt
  • track Socket.IO connection changes, reconnect jitter, hidden-tab reconciliation, query retries, ordinary mutations, and paused mutation queues
  • export the hook standalone and from createHooks(schema)
  • showcase the state in the demo navigation with offline, restoring, saving, error, and saved labels
  • document the API and adapter connection-state extension points

Why

Applications currently have to combine query state, useMutating(), mutation queue state, reconnect behavior, and observability events to answer a basic UI question: “is my data synchronized?” Events are intentionally non-replaying, so they cannot provide canonical state to components that mount mid-operation.

The new tracker is maintained synchronously alongside Figbird’s query and mutation state. Subscribers therefore receive the correct snapshot even when they mount during a fetch, queued write, disconnect, retry, or deferred reconciliation.

Validation

  • npm run test — 350 tests passing (typecheck, lint, Prettier, AVA)
  • npm --prefix demo exec tsc -- --noEmit
  • demo production build with Vite

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