I'm using a pattern where I have a communication channel that I use for a goroutine, and that channel is used to subscribe to a topic:
comms := make(chan interface{})
go func() {
for msg := range comms {
// do some stuff
}
}()
mySub.AddSub(comms, "some-topic")
The problem is now and then I change the topic that I'm interested in (in my code, it's when users move from one room to another room):
mySub.Unsub(comms, "some-topic")
mySub.AddSub(comms, "some-other-topic")
Unsub will close my channel if "some-topic" is the only topic that I'm listening to. Is there a way so that when unsubscribing, the pubsub lib doesn't automatically close my channel? I can't reverse the order of the Unsub/AddSub since in reality the code is a bit more asynchronous than the example above.
The workaround for now is to create a dummy topic that all channels are subscribed to but never actually broadcasts anything.