You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: revise hook architecture to granular query hooks with domain folders
Replace monolithic useEvents/usePortfolio hooks with granular
per-query hooks organized in domain folders (hooks/events/,
hooks/portfolio/). Each data hook triggers exactly one query so
components only fetch what they need. Imperative hooks (trading,
transactions, live-data) stay deep.
Update architecture.md, hooks.md, and README.md to reflect the
folder-based organization with barrel exports.
Copy file name to clipboardExpand all lines: app/components/UI/PredictNext/README.md
+8-1Lines changed: 8 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ Protocol adapters like PolymarketAdapter and the future KalshiAdapter handle ext
20
20
21
21
### Hooks
22
22
23
-
Seven hooks provide data and functionality to components. These include useEvents, usePortfolio, useTrading, useTransactions, useLiveData, usePredictNavigation, and usePredictGuard.
23
+
Hooks are organized by domain in co-located folders with barrel exports. Data hooks are granular — each triggers exactly one query so components only fetch what they need. Imperative hooks (useTrading, useTransactions, useLiveData) remain deep since they manage complex stateful workflows. Domains include events, portfolio, trading, transactions, live-data, navigation, and guard.
`useEvents` and `usePortfolio` should be thin wrappers around `useQuery` from `@metamask/react-data-query`. They provide query keys and parameters; the actual read logic lives in BaseDataService-backed services via messenger.
224
+
Event and portfolio hooks are granular — each hook triggers exactly one `useQuery`or `useInfiniteQuery` call from `@metamask/react-data-query`. This means a component that only needs the balance does not trigger position, activity, or P&L queries. The actual read logic lives in BaseDataService-backed services via messenger.
225
225
226
226
#### Deep imperative hooks
227
227
228
-
`useTrading`, `useTransactions`, and `useLiveData` remain somewhat deeper because they wrap imperative service operations and lifecycle concerns.
228
+
`useTrading`, `useTransactions`, and `useLiveData` remain deep because they wrap imperative service operations and lifecycle concerns (order state machines, transaction orchestration, WebSocket subscriptions).
229
229
230
230
#### Navigation and guard hooks
231
231
@@ -281,7 +281,7 @@ See [components.md](./components.md) for detail.
0 commit comments