From cd63ed1e4444f04395459d532dc950c302e535de Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Thu, 2 Apr 2020 12:07:23 -0400 Subject: [PATCH] Stop old subscription when it becomes reassigned as nil --- tea.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tea.go b/tea.go index 923bffc..c425a1e 100644 --- a/tea.go +++ b/tea.go @@ -269,10 +269,12 @@ func (p *Program) processSubs(msgs chan Msg, activeSubs subManager) subManager { return activeSubs } - // Stop subscriptions that don't exist in the new subscription map + // Stop subscriptions that don't exist in the new subscription map and + // stop subscriptions where the new subscription is mapped to a nil. if len(activeSubs) > 0 { for key, sub := range activeSubs { - if _, exists := newSubs[key]; !exists { + _, exists := newSubs[key] + if !exists || exists && newSubs[key] == nil { close(sub.done) delete(activeSubs, key) }