charmbracelet / charmbracelet/bubbletea

Example for two way communication with a background goroutine

Open
#1,244 7 comments 2 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
44.9k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

This is to request a new example showing two way communication between bubbletea and a background process (running as a goroutine.) There are already two examples (send-msg and realtime) which demonstrate one way communication with bubbletea, however it would seem to be a common use case to need two way communication.

For example, the background process may do some work and need to be able to push updates into the model so that the results can be displayed in the interface. But it also makes sense that the background process might want to change its behavior based on the user interacting with the interface, meaning it also needs to also be able to pull information from the model. It would be great to have an example showing this two way communication, a background goroutine that changes its behavior based on flags in the model, as well as the model being updated based on work done in the background goroutine.

Contributor guide

Open the contributing guide

Research direction

Start by reading the existing send-msg and realtime examples and the Bubble Tea model and message flow. Use those examples to define how a background goroutine can push updates into the model and respond to user-controlled model flags. Done means a runnable example demonstrates both communication directions and the resulting interface updates and behavior changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.