xchan

package
v0.0.0-...-9c03fb1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Completed = errors.New("completed")

Functions

func Observe

func Observe[T any](ctx context.Context, o Observer[T]) iter.Seq[T]

func Subscribe

func Subscribe[T any](ctx context.Context, source Observable[T], subscriber Subscriber[T])

func Values

func Values[T any](ctx context.Context, o ValueObservable[T]) iter.Seq[T]

Types

type Cancelable

type Cancelable interface {
	CancelCause(err error)
}

type NotifiableObserver

type NotifiableObserver[T any] interface {
	ValueNotifier[T]
	ValueObservable[T]
	Cancelable
	Done() <-chan struct{}
	Err() error
}

func NewNotifiableObserver

func NewNotifiableObserver[T any]() NotifiableObserver[T]

type Observable

type Observable[T any] interface {
	Observe() Observer[T]
}

type ObservableFunc

type ObservableFunc[T any] func() Observer[T]

func (ObservableFunc[T]) Observe

func (fn ObservableFunc[T]) Observe() Observer[T]

type Observer

type Observer[T any] interface {
	ValueObservable[T]
	Cancelable
	Done() <-chan struct{}
	Err() error
}

type Subject

type Subject[T any] struct {
	// contains filtered or unexported fields
}

func (*Subject[T]) CancelCause

func (c *Subject[T]) CancelCause(err error)

func (*Subject[T]) Done

func (c *Subject[T]) Done() <-chan struct{}

func (*Subject[T]) Err

func (c *Subject[T]) Err() error

func (*Subject[T]) Observe

func (c *Subject[T]) Observe() Observer[T]

func (*Subject[T]) Send

func (c *Subject[T]) Send(value T)

func (*Subject[T]) Subscribe

func (c *Subject[T]) Subscribe(o Subscriber[T])

type Subscriber

type Subscriber[T any] interface {
	ValueNotifier[T]
	Cancelable
	Done() <-chan struct{}
	Err() error
}

type ValueNotifier

type ValueNotifier[T any] interface {
	Send(x T)
}

type ValueObservable

type ValueObservable[T any] interface {
	Value() <-chan T
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL