lua

package
v0.0.6-alpha Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package lua exposes hex/events to Lua scripts as the "events" module.

local events = require("events")

events.emit("user.created", { id = 1, name = "alice" })
events.emit("app.ready")   -- no payload

v1 is emit-only. Subscribing from Lua ("events.on(...)") is a follow-up: cross-goroutine callbacks into an LState need careful serialisation (the LState is not thread-safe), and the REPL / scripting use cases don't need it yet. Go-side subscribers registered via app.On see Lua-emitted events immediately.

Index

Constants

This section is empty.

Variables

View Source
var TypeStub string

TypeStub is the Teal .d.tl source describing the `events` module.

Functions

This section is empty.

Types

type Bindings

type Bindings struct {
	// Emitter is the target for events.emit(). Required. Typically
	// *hex.App itself (which delegates to its *events.Bus).
	Emitter Emitter
}

Bindings configures the 'events' module.

func (*Bindings) Loader

func (b *Bindings) Loader(L *glua.LState) int

Loader is the gopher-lua LGFunction registered against env.PreloadModule("events", b.Loader).

type Emitter

type Emitter interface {
	Emit(event string, data ...any) error
}

Emitter is the small surface events.Bus (and *hex.App) expose to this module. Any type with Emit(event, data ...any) error works.

Jump to

Keyboard shortcuts

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