mirror of
https://github.com/clockworklabs/SpacetimeDB.git
synced 2026-05-09 00:59:46 -04:00
59ac77970f
Closes #4751 # Description of Changes - Add `useProcedure` React hook that mirrors `useReducer` which returns a stable, typed callback that queues calls until the connection is ready - Add `ProcedureParamsType` and `ProcedureReturnType` utility types to `type_utils.ts` - Update TypeScript codegen to emit `export const procedures = __convertToAccessorMap(proceduresSchema.procedures)` in generated module bindings, matching the existing pattern for reducers ```ts import { procedures } from './module_bindings'; import { useProcedure } from 'spacetimedb/react'; const doSomeThing = useProcedure(procedures.doSomeThing); const result = await doSomeThing({ foo: "..." }); ``` # API and ABI breaking changes None. Additive only — new hook export and new codegen line. # Expected complexity level and risk Low. The hook is a near-copy of `useReducer` adapted for procedure signatures. The codegen change adds one line following the identical pattern used for reducers. # Testing - [x] TypeScript SDK compiles with no new errors (`tsc --noEmit`) - [x] All 170 existing tests pass (17 test files) - [x] Tested end-to-end in a React app calling a procedure --------- Co-authored-by: Jason Larabie <jason@clockworklabs.io>