charmbracelet / charmbracelet/bubbletea
Pass Context to Init?
Open
question
v2
- Dominant language
- Go
- Stars
- 44.9k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
I have a use case like the HTTP example, except the external client expects a context:
```
type Client interface {
Call(context.Context)
}
type model struct {
client Client
}
func (m model) Init() {
m.client.Call( ¯\_(ツ)_/¯ )
}
```
What's the "right" way to structure this? I found `tea.WithContext` but it's not clear if or how I can actually access the program's context elsewhere. I could just do this with a channel (like the realtime example) or perhaps a closure, but I'm curious if there's a pattern you like for this kind of thing.
Thanks!
Contributor guide
Assessment
This issue has not been assessed yet.