events

package
v0.93.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package events pushes app events (session status, titles, touched — anything the backend pushes to the UI) to the local WebSocket client on /events (see docs/native-window.md). While no client is connected events are dropped — the window owns the connection, so nobody is listening anyway. It is also the delivery channel terminal I/O falls back to when the dedicated /ws transport is down.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Send added in v0.78.1

func Send[T any](emit func(name string, data any), e api.Event[T], payload T)

Send pushes payload as e through emit: the hub's Emit, or the copy of it a service was handed. The compiler holds payload to the type api declares for e; a None payload goes out as no data at all.

Types

type Envelope

type Envelope struct {
	Name string `json:"name"`
	Data any    `json:"data,omitempty"`
}

Envelope is one pushed event as it crosses the /events socket.

type Hub

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

func New

func New() *Hub

func (*Hub) Attached

func (h *Hub) Attached() bool

Attached reports whether a client is connected to hear what is emitted.

func (*Hub) Emit

func (h *Hub) Emit(name string, data any)

Emit pushes one event to the connected client; without one it is dropped.

func (*Hub) Gone added in v0.73.0

func (h *Hub) Gone() <-chan struct{}

Gone is closed once the client connected now leaves, and already closed with none connected. The client's process ends with its connection, so this is how lich waits for the window it told to close.

func (*Hub) Observe added in v0.89.0

func (h *Hub) Observe(fn func(name string, data any))

Observe hands fn every event emitted from now on, a client connected or not. fn runs on the emitter's goroutine and must not block.

func (*Hub) ServeHTTP

func (h *Hub) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP upgrades /events. One client is expected (the shell); a new connection replaces the previous one. The read loop only watches for close. Token auth is applied by the transport mount, like every mounted handler.

Jump to

Keyboard shortcuts

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