dynamo-browse/internal/common/ui/dispatcher/context.go
Leon Mika 7526c095ee sqs-browse: a lot of work to try to keep UI complexity down
Added the notion of controllers and a dispatcher which will queue up operations
2022-03-23 15:40:31 +11:00

31 lines
720 B
Go

package dispatcher
import (
"fmt"
tea "github.com/charmbracelet/bubbletea"
"github.com/lmika/awstools/internal/common/ui/events"
"github.com/lmika/awstools/internal/common/ui/uimodels"
)
type dispatcherContext struct {
d *Dispatcher
}
func (dc dispatcherContext) Messagef(format string, args ...interface{}) {
dc.d.publisher.Send(events.Message(fmt.Sprintf(format, args...)))
}
func (dc dispatcherContext) Send(teaMessage tea.Msg) {
dc.d.publisher.Send(teaMessage)
}
func (dc dispatcherContext) Message(msg string) {
dc.d.publisher.Send(events.Message(msg))
}
func (dc dispatcherContext) Input(prompt string, onDone uimodels.Operation) {
dc.d.publisher.Send(events.PromptForInput{
OnDone: onDone,
})
}