CallDeclaration
Available since
@irtio/room 0.1Hosted roomsirt dev@irtio/testingSelf-hosted room hostThe CallDeclaration interface of the Room API is one call as call() declares it: the fields of its args, and the type of its reply. Pass it to defineCalls().
Instance properties
CallDeclaration.fields- The fields of the args, as
call()was given them. Read only.
Instance methods
CallDeclaration.returns()- Declares the reply’s type,
returns<T>(), and returns the declaration typed with it. Without it, the reply isvoid. It’s only a type: the room doesn’t check what a handler returns.
Examples
Typing a reply
// lookup.ts
import { call, defineCalls, defineRoom, defineSchema } from "@irtio/room";
const schema = defineSchema({
calls: defineCalls({ whois: call({ player: "string" }).returns<{ online: boolean }>() }),
});
export default defineRoom({
schema,
calls: {
whois: ({ player }, { room }) => ({ online: room.presence.get(player)?.connected ?? false }),
},
});
See also
Runtime availability
| Hosted rooms | irt dev | @irtio/testing | Self-hosted room host | |
|---|---|---|---|---|
CallDeclaration | 0.1 | 0.1 | 0.1 | 0.1 |