https://github.com/ReactiveX/RxGo#connectable-observable
The documentation shows the following
disposed, cancel := observable.Connect()
go func() {
// Do something
time.Sleep(time.Second)
// Then cancel the subscription
cancel()
}()
// Wait for the subscription to be disposed
<-disposed
But now, connect takes a context. The API has changed and it should be something like this
ctx, cancelFunc := observable.Connect(context.Background())
go func() {
// Do something
time.Sleep(time.Second)
// Then cancel the subscription
cancelFunc()
}()
// Wait for the subscription to be disposed
<-ctx.Done()