Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrClientAlreadyDeRegistered = errors.New("client already de-registered")
Functions ¶
This section is empty.
Types ¶
type CancelFunc ¶
type CancelFunc func() error
type Observable ¶
type Observable[T any] interface { // Subscribe registers a client to the observable. Subscribe() (<-chan T, CancelFunc) // NotifyAll notifies all registered clients. NotifyAll(data T) }
Observable
type Observer ¶
type Observer[T any] struct { NotifyTimeout time.Duration // contains filtered or unexported fields }
Observer offers the possibility to notify all registered clients. Since the client map must be initialized, it is not possible to use this structure directly. Use NewObserver instead.
func (*Observer[T]) NotifyAll ¶
func (o *Observer[T]) NotifyAll(data T)
NotifyAll notifies all registered clients.
func (*Observer[T]) Subscribe ¶
func (o *Observer[T]) Subscribe() (<-chan T, CancelFunc)
Subscribe registers a client to the observer and returns a channel to receive notifications. The returned CancelFunc can be used to de-register the client.
Click to show internal directories.
Click to hide internal directories.