RxGo
RxGo copied to clipboard
How to stop a Interval observable?
I'm missing a close, unsubscribe, dispose, etc. function? How am I supposed to stop it?
I think you're going to need to use Connect
so that it returns to you a Context
and a Disposable
. See observable_operator.go:596
.
// Connect instructs a connectable Observable to begin emitting items to its subscribers.
func (o *ObservableImpl) Connect(ctx context.Context) (context.Context, Disposable) {
ctx, cancel := context.WithCancel(ctx)
o.Observe(WithContext(ctx), connect())
return ctx, Disposable(cancel)
}
Once you have a Disposable, you have a cancel func to dispose of the subscription. See types.go:41
.
// Disposable is a function to be called in order to dispose a subscription.
Disposable context.CancelFunc