event

package
v0.74.1 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package event defines typed event structures for system-wide event bus communication including file changes, git updates, and UI refresh notifications.

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 handles fan-out event routing between plugins.

func New

func New() *Dispatcher

New creates a new event dispatcher.

func NewWithLogger

func NewWithLogger(logger *slog.Logger) *Dispatcher

NewWithLogger creates a dispatcher with custom logger.

func (*Dispatcher) Close

func (d *Dispatcher) Close()

Close shuts down the dispatcher and all subscriber channels.

func (*Dispatcher) Publish

func (d *Dispatcher) Publish(topic string, e Event)

Publish sends an event to all subscribers of a topic. Non-blocking: drops events if subscriber buffer is full.

func (*Dispatcher) PublishAll

func (d *Dispatcher) PublishAll(e Event)

PublishAll sends an event to all subscribers of all topics.

func (*Dispatcher) Subscribe

func (d *Dispatcher) Subscribe(topic string) <-chan Event

Subscribe creates a buffered channel for receiving events on a topic.

type Event

type Event struct {
	Type      Type
	Topic     string
	Timestamp time.Time
	Data      any
}

Event represents a typed event in the system.

func NewEvent

func NewEvent(t Type, topic string, data any) Event

NewEvent creates a new event with the current timestamp.

type Type

type Type string

Type identifies the kind of event.

const (
	// File change events
	TypeFileChanged Type = "file_changed"
	TypeGitChanged  Type = "git_changed"
	TypeSessionFile Type = "session_file"

	// Data update events
	TypeTDUpdate      Type = "td_update"
	TypeSessionUpdate Type = "session_update"

	// UI events
	TypeFocusChanged  Type = "focus_changed"
	TypeRefreshNeeded Type = "refresh_needed"

	// Error events
	TypeError Type = "error"
)

Jump to

Keyboard shortcuts

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