mirror of
https://github.com/taigrr/bubbletea.git
synced 2026-04-02 02:59:09 -07:00
Stop old subscription when it becomes reassigned as nil
This commit is contained in:
6
tea.go
6
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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user