events

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dispatcher

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

Dispatcher manages event listeners and dispatches events.

func NewDispatcher

func NewDispatcher() *Dispatcher

NewDispatcher returns an empty event dispatcher.

func (*Dispatcher) Dispatch

func (d *Dispatcher) Dispatch(event string, payload interface{})

Dispatch fires all handlers for the event asynchronously.

func (*Dispatcher) DispatchSync

func (d *Dispatcher) DispatchSync(event string, payload interface{})

DispatchSync fires all handlers for the event sequentially.

func (*Dispatcher) Has

func (d *Dispatcher) Has(event string) bool

Has returns true if any listener is registered for the event.

func (*Dispatcher) Listen

func (d *Dispatcher) Listen(event string, handler Handler)

Listen registers a handler for the named event.

type Handler

type Handler func(payload interface{})

Handler is a function that handles an event.

Jump to

Keyboard shortcuts

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