Skip to main content

View as Markdown · AI documentation index

Function: defineMessenger()

defineMessenger(options): Messenger

Defined in: messenger.ts:110

Configures messenger-wide behaviour and returns the cross-chat facade.

Parameters​

options​

MessengerOptions = {}

Store-wide callbacks, chat order, and the seen store

Returns​

Messenger

The messenger facade

Remarks​

Optional: chats work without it. Call it to register callbacks that should fire for every chat, to fix the order of the chat list, or to swap the seen store. Calling it again merges the new options over the old ones.

Example​

import { defineMessenger } from '@react-text-game/messenger';

export const messenger = defineMessenger({
chats: [annaChat, squad, news],
onSend: ({ chat, entry }) => {
if (entry.from !== 'player') incoming.play();
},
});

await messenger.loadSeen();