Skip to content
Myr

Commands should probably receive the model as an arg, right?

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Christian Rocha · committed by Christian Rocha · parent 5156905 · Browse files · 6 files+32 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

6 files+32 added−6 removed

  • other:+32 added−6 removed

6 files+32 added−6 removed

modified:examples/http/main.go+1 added-1 removed
71 unmodified lines
72 }73 return fmt.Sprintf("The server said: %d %s", m.Status, http.StatusText(m.Status))74}7576func checkServer() tea.Msg {76func checkServer(_ tea.Model) tea.Msg {77 c := &http.Client{78 Timeout: 10 * time.Second,79 }80 res, err := c.Get(url)
5 unmodified lines
added:examples/go.mod+10 added
1module examples23go 1.1345require (6 github.com/charmbracelet/tea v0.0.0-20200120035228-5156905c3e107 github.com/charmbracelet/teaparty v0.0.0-20200118155738-c83a0bee59b98 github.com/fogleman/ease v0.0.0-20170301025033-8da417bf17769 golang.org/x/sys v0.0.0-20200120151820-655fe14d7479 // indirect10)
added:examples/go.sum+11 added
1github.com/charmbracelet/tea v0.0.0-20200118154546-df52853f9d94/go.mod h1:lijy1lXOKNwMjBu/jTT/DvR8yE9PhtX2olGFsCz9/Vk=2github.com/charmbracelet/tea v0.0.0-20200120035228-5156905c3e10 h1:C8gRihuPFEUON+BsEe4SsKDfHhgZlStosn9YvE+mtjU=3github.com/charmbracelet/tea v0.0.0-20200120035228-5156905c3e10/go.mod h1:lijy1lXOKNwMjBu/jTT/DvR8yE9PhtX2olGFsCz9/Vk=4github.com/charmbracelet/teaparty v0.0.0-20200118155738-c83a0bee59b9 h1:YQvJgppGVexnzIJ+KJlK9lBYA3+zXfdqZO/5Ngedtb0=5github.com/charmbracelet/teaparty v0.0.0-20200118155738-c83a0bee59b9/go.mod h1:z8JWtuxM0oA+dZfi7BkgBW2YGbyOTbWAixFs46W3SK4=6github.com/fogleman/ease v0.0.0-20170301025033-8da417bf1776 h1:VRIbnDWRmAh5yBdz+J6yFMF5vso1It6vn+WmM/5l7MA=7github.com/fogleman/ease v0.0.0-20170301025033-8da417bf1776/go.mod h1:9wvnDu3YOfxzWM9Cst40msBF1C2UdQgDv962oTxSuMs=8github.com/pkg/term v0.0.0-20190109203006-aa71e9d9e942 h1:A7GG7zcGjl3jqAqGPmcNjd/D9hzL95SuoOQAaFNdLU0=9github.com/pkg/term v0.0.0-20190109203006-aa71e9d9e942/go.mod h1:eCbImbZ95eXtAUIbLAuAVnBnwf83mjf6QIVH8SHYwqQ=10golang.org/x/sys v0.0.0-20200120151820-655fe14d7479 h1:LhLiKguPgZL+Tglay4GhVtfF0kb8cvOJ0dHTCBO8YNI=11golang.org/x/sys v0.0.0-20200120151820-655fe14d7479/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
modified:go.mod+4 added-1 removed
1module github.com/charmbracelet/tea23go 1.1345require (5require github.com/pkg/term v0.0.0-20190109203006-aa71e9d9e9426 github.com/pkg/term v0.0.0-20190109203006-aa71e9d9e9427 golang.org/x/sys v0.0.0-20200120151820-655fe14d7479 // indirect8)
modified:go.sum+2 added
1github.com/pkg/term v0.0.0-20190109203006-aa71e9d9e942 h1:A7GG7zcGjl3jqAqGPmcNjd/D9hzL95SuoOQAaFNdLU0=2github.com/pkg/term v0.0.0-20190109203006-aa71e9d9e942/go.mod h1:eCbImbZ95eXtAUIbLAuAVnBnwf83mjf6QIVH8SHYwqQ=3golang.org/x/sys v0.0.0-20200120151820-655fe14d7479 h1:LhLiKguPgZL+Tglay4GhVtfF0kb8cvOJ0dHTCBO8YNI=4golang.org/x/sys v0.0.0-20200120151820-655fe14d7479/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
modified:tea.go+4 added-4 removed
15 unmodified lines
16// Model contains the updatable data for an application17type Model interface{}1819// Cmd is an IO operation. If it's nil it's considered a no-op.20type Cmd func() Msg20type Cmd func(Model) Msg2122// Sub is an event subscription. If it returns nil it's considered a no-op.23type Sub func(Model) Msg24
34 unmodified lines
59 return ErrMsg{errors.New(s)}60}6162// Quit is a command that tells the program to exit63func Quit() Msg {63func Quit(_ Model) Msg {64 return quitMsg{}65}6667// Signals that the program should quit
52 unmodified lines
120 msgs <- KeyMsg(msg)121 }122 }()123124 // Initialize subscriptions124 // Process subscriptions125 go func() {126 if len(p.subscriptions) > 0 {127 for _, sub := range p.subscriptions {128 go func(s Sub) {
13 unmodified lines
142 return143 case cmd := <-cmds:144 if cmd != nil {145 go func() {146 msgs <- cmd()146 msgs <- cmd(model)147 }()148 }149 }150 }
46 unmodified lines