xmtp / xmtp-js

XMTP client SDKs, content types, and other packages written in TypeScript
https://xmtp.org/docs
211 stars 40 forks source link

Add `streamAllMessages()` snippet to readme #214

Closed joshuasorkin closed 1 year ago

joshuasorkin commented 1 year ago

Based on the conversation in https://discord.com/channels/831836269558235136/993229186951028796/1039310518348951653, I think it would be a good idea to add a snippet to the readme that illustrates use of streamAllMessages(). I'm thinking the easiest way would be to update the instructions at https://xmtp.org/docs/client-sdk/javascript/tutorials/quickstart#listen-for-new-messages-in-a-conversation, adding at the bottom:

To listen for any incoming messages from all conversations, use streamAllMessages():

for await (const message of await xmtp.conversations.streamAllMessages()) {

 if (message.senderAddress === xmtp.address) {
   // This message was sent from me
   continue
 }
 console.log(`New message from ${message.senderAddress}: ${message.content}`)
}

I'd be happy to take this on if you want to assign it to me.

github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 7.1.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket: