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
Provenance
- Commit
e1d4a14- Tree
5f23e4c- Author
Christian Rocha <christian@rocha.is>- Committer
Christian Rocha <christian@rocha.is>- Parent
5156905
6 files changed+32 added−6 removed
modified:examples/http/main.go+1 added-1 removed
71 unmodified lines72 }73 return fmt.Sprintf("The server said: %d %s", m.Status, http.StatusText(m.Status))74 }75 76-func checkServer() tea.Msg {76+func checkServer(_ tea.Model) tea.Msg {77 c := &http.Client{78 Timeout: 10 * time.Second,79 }80 res, err := c.Get(url)5 unmodified linesadded:examples/go.mod+10 added
1+module examples2+3+go 1.134+5+require (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
1+github.com/charmbracelet/tea v0.0.0-20200118154546-df52853f9d94/go.mod h1:lijy1lXOKNwMjBu/jTT/DvR8yE9PhtX2olGFsCz9/Vk=2+github.com/charmbracelet/tea v0.0.0-20200120035228-5156905c3e10 h1:C8gRihuPFEUON+BsEe4SsKDfHhgZlStosn9YvE+mtjU=3+github.com/charmbracelet/tea v0.0.0-20200120035228-5156905c3e10/go.mod h1:lijy1lXOKNwMjBu/jTT/DvR8yE9PhtX2olGFsCz9/Vk=4+github.com/charmbracelet/teaparty v0.0.0-20200118155738-c83a0bee59b9 h1:YQvJgppGVexnzIJ+KJlK9lBYA3+zXfdqZO/5Ngedtb0=5+github.com/charmbracelet/teaparty v0.0.0-20200118155738-c83a0bee59b9/go.mod h1:z8JWtuxM0oA+dZfi7BkgBW2YGbyOTbWAixFs46W3SK4=6+github.com/fogleman/ease v0.0.0-20170301025033-8da417bf1776 h1:VRIbnDWRmAh5yBdz+J6yFMF5vso1It6vn+WmM/5l7MA=7+github.com/fogleman/ease v0.0.0-20170301025033-8da417bf1776/go.mod h1:9wvnDu3YOfxzWM9Cst40msBF1C2UdQgDv962oTxSuMs=8+github.com/pkg/term v0.0.0-20190109203006-aa71e9d9e942 h1:A7GG7zcGjl3jqAqGPmcNjd/D9hzL95SuoOQAaFNdLU0=9+github.com/pkg/term v0.0.0-20190109203006-aa71e9d9e942/go.mod h1:eCbImbZ95eXtAUIbLAuAVnBnwf83mjf6QIVH8SHYwqQ=10+golang.org/x/sys v0.0.0-20200120151820-655fe14d7479 h1:LhLiKguPgZL+Tglay4GhVtfF0kb8cvOJ0dHTCBO8YNI=11+golang.org/x/sys v0.0.0-20200120151820-655fe14d7479/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=modified:go.mod+4 added-1 removed
1 module github.com/charmbracelet/tea2 3 go 1.134 5+require (5-require 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
1 github.com/pkg/term v0.0.0-20190109203006-aa71e9d9e942 h1:A7GG7zcGjl3jqAqGPmcNjd/D9hzL95SuoOQAaFNdLU0=2 github.com/pkg/term v0.0.0-20190109203006-aa71e9d9e942/go.mod h1:eCbImbZ95eXtAUIbLAuAVnBnwf83mjf6QIVH8SHYwqQ=3+golang.org/x/sys v0.0.0-20200120151820-655fe14d7479 h1:LhLiKguPgZL+Tglay4GhVtfF0kb8cvOJ0dHTCBO8YNI=4+golang.org/x/sys v0.0.0-20200120151820-655fe14d7479/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=modified:tea.go+4 added-4 removed
15 unmodified lines16 // Model contains the updatable data for an application17 type Model interface{}18 19 // Cmd is an IO operation. If it's nil it's considered a no-op.20-type Cmd func() Msg20+type Cmd func(Model) Msg21 22 // Sub is an event subscription. If it returns nil it's considered a no-op.23 type Sub func(Model) Msg24 34 unmodified lines59 return ErrMsg{errors.New(s)}60 }61 62 // Quit is a command that tells the program to exit63-func Quit() Msg {63+func Quit(_ Model) Msg {64 return quitMsg{}65 }66 67 // Signals that the program should quit52 unmodified lines120 msgs <- KeyMsg(msg)121 }122 }()123 124- // 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 lines142 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