A record mapping registry keys to their corresponding RpcGroup.RpcGroup instances.
Retrieves a registered handler group by its tag with full type safety.
The tag of the handler group to retrieve.
The tag associated with the desired handler group.
The TaggedRPCGroup corresponding to the specified tag.
Retrieves all registered tags in the registry.
An array of all tags currently registered.
Registers a new RPC handler group and immediately returns the registered handler for the given tag. The tag must not already exist in the registry.
This is useful to re-use the TaggedHandler
directly.
The unique tag for the handler group.
The handler group instance to register.
The TaggedRPCGroup for the newly registered group.
export const helloRouter = RpcGroup.make(
Rpc.fromTaggedRequest(SayHelloReq),
Rpc.fromTaggedRequest(SayByeReq),
);
export const helloRequests = createRpcGroupRegistry().registerGetGroup('hello', helloRouter);
It registers the hello group and returns it. Then you can do something like:
// in /app/api/route.ts, for example
import { helloRequests } from './requests';
const program = helloRequests.getRequest('SayHelloReq', { name });
This is shorter than just using registerGroup
which would require to get the hello
handlers first.
Registers a new RPC handler group under the specified tag. The tag must not already exist in the registry.
The unique tag for the handler group.
The handler group instance to register.
A new RpcGroupRegistry instance including the newly registered group.
Represents a registry for managing groups of RPC handlers, providing type-safe operations for registering, retrieving, and querying handler groups by their unique tags.
Since
0.8.0