Skip to content

Teardown: Add a variant receiving context as parameter #115

@samber

Description

@samber

And add UnsubscribeWithContext(context.Context) method to ro.Subscription interface.

func MyOperator[T any]() func(Observable[T]) Observable[[]T] {
	return func(source Observable[T]) Observable[[]T] {
		return NewUnsafeObservableWithContext(func(subscriberCtx context.Context, destination Observer[[]T]) Teardown {
			sub := source.SubscribeWithContext(
				subscriberCtx,
				NewObserverWithContext(
					...
				),
			)

			return func(unsubscriberCtx context.Context) {
                                sub.UnsubscribeWithContext(unsubscriberCtx)
                         }
		})
	}
}

Don't forget to update documentation:

  • hacking
  • contributing

Metadata

Metadata

Assignees

No one assigned

    Labels

    coreChanges affecting the core logic or main components of the project, in root/internal/testing pkgdiscussionGeneral discussion, proposal, or open-ended topic not tied to a specific bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions