TLCustomMessageHandler
Handler function for custom application messages sent through the sync protocol. These are user-defined messages that can be sent between clients via the sync server, separate from the standard document synchronization messages.
type TLCustomMessageHandler = (this: null, data: any) => void;Example
const customMessageHandler: TLCustomMessageHandler = (data) => {
if (data.type === "user_joined") {
console.log(`${data.username} joined the session`);
showToast(`${data.username} is now collaborating`);
}
};
const syncClient = new TLSyncClient({
// ... other config
onCustomMessageReceived: customMessageHandler,
});Parameters
| Name | Description |
|---|---|
| Custom message payload (application-defined structure) |
Prev
SubscribingFnNext
TLPresenceMode