events

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2023 License: MIT Imports: 1 Imported by: 0

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.

type EventType

type EventType string

EventType represents the type of event.

Jump to

Keyboard shortcuts

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