onConversationRemoved
Sets up a listener for when a message is deleted from a conversation.
Usage
const creatorAddress = '0x...';
const conversationHash = '0x...';
// Listen to all conversations removed by the specified sender
chat.onConversationRemoved(creatorAddress, null, (sender, conversationHash) => {
console.log(sender);
console.log(conversationHash);
});
// Listen to a specific conversation removed by any sender
chat.onConversationRemoved(null, conversationHash, (sender, conversationHash) => {
console.log(sender);
console.log(conversationHash);
});
// Listen to any conversation removal events
chat.onConversationRemoved(null, null, (sender, conversationHash) => {
console.log(sender);
console.log(conversationHash);
});
Stop watching
// Listen to any conversation removal events
const stopWatching = chat.onConversationRemoved(null, null, (sender, conversationHash) => {
console.log(sender);
console.log(conversationHash);
});
// ... 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 conversation creator's address who deleted the conversation. If set to null, it listens for conversations removed by any sender.
conversationHash
- Type
ConversationHash | null
The hash of the target conversation that got removed. If set to null, it listens for the removal of any conversation.
callback
- Type
(sender: Address, conversationHash: ConversationHash) => void
A callback function that will be executed when a conversation removal event is detected. This callback is passed two arguments:
sender
: The creator's address who removed the conversation.conversationHash
: The hash of the removed conversation.