Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to stop a Interval observable? #277

Open
Robert-M-Muench opened this issue Dec 5, 2020 · 1 comment
Open

How to stop a Interval observable? #277

Robert-M-Muench opened this issue Dec 5, 2020 · 1 comment
Assignees
Labels
enhancement Enhancement.

Comments

@Robert-M-Muench
Copy link

I'm missing a close, unsubscribe, dispose, etc. function? How am I supposed to stop it?

@darrensapalo
Copy link
Contributor

darrensapalo commented Dec 5, 2020

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

@teivah teivah added the enhancement Enhancement. label Apr 6, 2021
@si3nloong si3nloong linked a pull request Aug 29, 2022 that will close this issue
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants