diff --git a/examples/fullscreen/main.go b/examples/fullscreen/main.go index 2d526a5..8d7a18f 100644 --- a/examples/fullscreen/main.go +++ b/examples/fullscreen/main.go @@ -55,7 +55,7 @@ func update(message tea.Msg, mdl tea.Model) (tea.Model, tea.Cmd) { func subscriptions(_ tea.Model) tea.Subs { return tea.Subs{ - "tick": func(_ tea.Model) tea.Msg { + "tick": func() tea.Msg { time.Sleep(time.Second) return tickMsg{} }, diff --git a/examples/simple/main.go b/examples/simple/main.go index 56e111f..6070821 100644 --- a/examples/simple/main.go +++ b/examples/simple/main.go @@ -59,7 +59,7 @@ func view(model tea.Model) string { // second, sends a tick, and then restarts. func subscriptions(_ tea.Model) tea.Subs { return tea.Subs{ - "tick": func(_ tea.Model) tea.Msg { + "tick": func() tea.Msg { time.Sleep(time.Second) return TickMsg{} }, diff --git a/examples/views/main.go b/examples/views/main.go index dd80950..485a627 100644 --- a/examples/views/main.go +++ b/examples/views/main.go @@ -58,12 +58,12 @@ func subscriptions(model tea.Model) tea.Subs { } } -func tick(model tea.Model) tea.Msg { +func tick() tea.Msg { time.Sleep(time.Second) return tickMsg{} } -func frame(model tea.Model) tea.Msg { +func frame() tea.Msg { time.Sleep(time.Second / 60) return frameMsg{} } diff --git a/tea.go b/tea.go index 1fbc1ee..ed60361 100644 --- a/tea.go +++ b/tea.go @@ -32,17 +32,7 @@ func Batch(cmds ...Cmd) Cmd { // Sub is an event subscription; generally a recurring IO operation. If it // returns nil it's considered a no-op, but there's really no reason to have // a nil subscription. -type Sub func(Model) Msg - -// SubMap applies a given model as an argument to a given subscription. -func SubMap(sub Sub, model Model) Sub { - if sub == nil { - return nil - } - return func(_ Model) Msg { - return sub(model) - } -} +type Sub func() Msg // Subs is a keyed set of subscriptions. The key should be a unique // identifier: two different subscriptions should not have the same key or @@ -280,7 +270,7 @@ func (p *Program) processSubs(msgs chan Msg, model Model, activeSubs subManager) select { case <-done: return - case msgs <- s(model): + case msgs <- s(): continue } }