Zum Inhalt springen
Kitbay
Skill

data-fetching-architecture

NOASSERTIONAktualisiert am 11. Nov. 202684.974GitHub-Sterne

A reference skill in the LobeHub repository, not called directly by users, on how server data moves through LobeHub's web front end.

Was der Skill vermittelt

A reference skill in the LobeHub repository, not called directly by users, on how server data moves through LobeHub's web front end. Services own API calls, stores expose fetch hooks that keep a replica of server data, and components read through selectors. New server data must use the project's replica library rather than new SWR keys, which a test freezes. It covers keeping read and refresh parameters the same, skipping requests without a required ID, avoiding fetches in effects, optimistic updates with rollback, telling an unloaded result from an empty one, showing first-load errors, keeping content during background failures, and moving old effect-based fetching into store hooks.

Funktionen

  • Add server data through replica-backed store hooks
  • Write mutations with optimistic updates and rollback
  • Render loading, empty and error states correctly
  • Migrate effect-based fetching to store hooks