Skip to content

Updated Realtime Example#1243

Closed
FFCoder wants to merge 3 commits intocharmbracelet:mainfrom
FFCoder:main
Closed

Updated Realtime Example#1243
FFCoder wants to merge 3 commits intocharmbracelet:mainfrom
FFCoder:main

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.

@FFCoder
Copy link
Author

FFCoder commented Feb 25, 2025

@meowgorithm or @aymanbagabas would either of you mind reviewing this?

@FFCoder FFCoder closed this Mar 19, 2025
@meowgorithm
Copy link
Member

Hey @FFCoder. Apologies for the delay on this one: we've been very backlogged. This is a helpful PR and wed be happy to merge it with some changes (notably, I'd use the tea.Println() command to print messages).

If you're willing to reopen it we'd be happy to make those changes and merge it.

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.

3 participants