TUI IDE multiplexer?!
golang tui ide
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Properly unsubscribe using wildcards

kettek 5a3b299b 00b9b729

+6 -5
+6 -5
bus.go
··· 62 62 return b.topID 63 63 } 64 64 65 - // Unsubscribes removes a subscription for a topic using the given id. Returns true on success, false if the topic or id was not found. 66 - func (b *Bus) Unsubscribe(topic string, id int) bool { 67 - if t, ok := b.topics[topic]; ok { 65 + // Unsubscribes removes a subscription for a topic using the given id. Returns the number of subscriptions removed. 66 + func (b *Bus) Unsubscribe(topic string, id int) (count int) { 67 + for _, t := range b.topics { 68 68 for index, s := range t.subscriptions { 69 69 if s.id == id { 70 70 t.subscriptions = append(t.subscriptions[:index], t.subscriptions[index+1:]...) 71 - return true 71 + count++ 72 + break 72 73 } 73 74 } 74 75 } 75 - return false 76 + return count 76 77 } 77 78 78 79 type Subscription struct {