Listening
Use the listen
method to start the listening for incoming events.
type ChatMessageType = {
message: string;
};
const onChatMessage = socketInstance.createListener<ChatMessageType>()({
endpoint: "chat-message", // endpoint of the event
});
onChatMessage.listen((message) => {
console.log(message); // ChatMessageType
});