Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Realtime Example #1243

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Updated Realtime Example #1243

wants to merge 3 commits into from

Conversation

FFCoder
Copy link

@FFCoder FFCoder commented Nov 19, 2024

Per Issue #1242 updated the real time example to grab some random chat messages and send it down the channel. This will be used to demonstrate how a production application could send messages over a channel.

Largely, I tried to limit changes as much as possible other than what is needed. I'm still new-ish to Golang so I welcome criticism or if we want to go another way with this I'm happy to change!

@mdepot
Copy link

mdepot commented Nov 19, 2024

Thanks, this is already helpful. Prior to this there were a number of places where the channel was just defined as struct{}. Now it's obvious that responsMsg is the type that should be on the channel, and that is key to understanding this example.

@mdepot
Copy link

mdepot commented Nov 19, 2024

In retrospect, since responseMsg was already defined then just substituting chan responseMsg for all the chan struct{} and sub <- responseMsg{} for sub <- struct{}{} might have made it clear enough, even without passing any data inside the responseMsg.

Copy link

@mdepot mdepot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this would still work ok if ChatMessage was private (lower case). If not, please help me understand why it might be good to leave it exported.

Also, printing Last Message could use a leading space for alignment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants