Stop old subscription when it becomes reassigned as nil

This commit is contained in:
Christian Rocha 2020-04-02 12:07:23 -04:00
parent 2e509ad32c
commit cd63ed1e44
No known key found for this signature in database
GPG Key ID: D6CC7A16E5878018
1 changed files with 4 additions and 2 deletions

6
tea.go
View File

@ -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)
}