onGroupConversationCreated
Sets up a listener for when a new group conversation is created.
Usage
const creatorAddress = '0x...';
// Listen to all group conversations created by the specified sender
chat.onGroupConversationCreated(
creatorAddress,
(sender, conversationHash, conversationName, members) => {
console.log(sender);
console.log(conversationHash);
console.log(conversationName);
console.log(members);
},
);
// Listen to all group conversations created by any sender
chat.onGroupConversationCreated(null, (sender, conversationHash, conversationName, members) => {
console.log(sender);
console.log(conversationHash);
console.log(conversationName);
console.log(members);
});
Stop watching
// Listen to all group conversations created by any sender
const stopWatching = chat.onGroupConversationCreated(
null,
(sender, conversationHash, conversationName, members) => {
console.log(sender);
console.log(conversationHash);
console.log(conversationName);
console.log(members);
},
);
// ... Later, to stop watching for the events
stopWatching();
Returns
UnwatchFn
A function that can be invoked to stop watching for new event logs.
Parameters
sender
- Type
Address | null
The group creator's address. If set to null, it listens for group conversations created by any sender.
callback
- Type
(sender: Address, conversationHash: ConversationHash, conversationName: string, members: Address[]) => void
A callback function that will be executed when a new group conversation is detected. This callback is passed four arguments:
sender
: The creator's address.conversationHash
: The hash of the created conversation.conversationName
: The name of the group conversation.members
: Array containing the addresses of the members of the created group conversation.