Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PublishEvent ¶
func PublishEvent(event Event)
PublishEvent calls each handler with the provided event. It locks the mutex before iterating over the handlers and unlocks it after. Each handler is called in a new goroutine for non-blocking event notifications.
func Subscribe ¶
func Subscribe(handler EventHandler)
Subscribe adds a new event handler to the handlers slice. It locks the mutex before appending to the slice and unlocks it after.
Types ¶
type Event ¶
type Event struct {
Type EventType // The type of the event.
Message string // The message of the event.
}
Event represents an event with a type and a message.
type EventHandler ¶
type EventHandler func(Event)
EventHandler represents a function that handles an event.
Click to show internal directories.
Click to hide internal directories.