bus

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Publish

func Publish[T Bus](broker *Dispatcher, ev T)

Publish writes an event into the dispatcher

func Subscribe

func Subscribe[T Bus](broker *Dispatcher, handler func(T)) context.CancelFunc

Subscribe subscribes to an event, the type of the event will be automatically inferred from the provided type. Must be constant for this to work.

func SubscribeTo

func SubscribeTo[T Bus](broker *Dispatcher, eventType uint32, handler func(T)) context.CancelFunc

SubscribeTo subscribes to an event with the specified event type.

Types

type Bus

type Bus interface {
	Type() uint32
}

Bus represents an event contract

type Dispatcher

type Dispatcher struct {
	// contains filtered or unexported fields
}

Dispatcher represents an event dispatcher.

func NewDispatcher

func NewDispatcher() *Dispatcher

NewDispatcher creates a new dispatcher of events.

func (*Dispatcher) Close

func (d *Dispatcher) Close() error

Close closes the dispatcher

Jump to

Keyboard shortcuts

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