events

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventManager

type EventManager interface {
	// Subscribe returns a channel that receives events for the specified page
	Subscribe(ctx context.Context, pageID string) (<-chan UIEvent, error)
	// Publish sends an event for the specified page
	Publish(pageID string, event UIEvent) error
	// Close cleans up resources used by the event manager
	Close() error
}

EventManager defines the interface for managing UI events

type UIEvent

type UIEvent struct {
	Type      string      `json:"type"`                // e.g. "component-update", "page-reload"
	PageID    string      `json:"pageId"`              // Which page is being updated
	Component interface{} `json:"component"`           // The updated component data
	RequestID string      `json:"requestId,omitempty"` // Optional request ID for tracking user actions
}

UIEvent represents an event in the UI system that can trigger updates

func FromJSON

func FromJSON(data []byte) (UIEvent, error)

FromJSON creates an event from JSON bytes

func NewPageReloadEvent

func NewPageReloadEvent(pageID string, pageDef interface{}) UIEvent

NewPageReloadEvent creates a new event for reloading a page

func (UIEvent) ToJSON

func (e UIEvent) ToJSON() ([]byte, error)

ToJSON converts the event to JSON bytes

func (UIEvent) Validate

func (e UIEvent) Validate() error

Validate checks if the event is valid

type WatermillEventManager

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

WatermillEventManager implements EventManager using Watermill

func NewWatermillEventManager

func NewWatermillEventManager(logger *zerolog.Logger) (*WatermillEventManager, error)

NewWatermillEventManager creates a new WatermillEventManager

func (*WatermillEventManager) Close

func (m *WatermillEventManager) Close() error

Close implements EventManager.Close

func (*WatermillEventManager) Publish

func (m *WatermillEventManager) Publish(pageID string, event UIEvent) error

Publish implements EventManager.Publish

func (*WatermillEventManager) Subscribe

func (m *WatermillEventManager) Subscribe(ctx context.Context, pageID string) (<-chan UIEvent, error)

Subscribe implements EventManager.Subscribe

Jump to

Keyboard shortcuts

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