hooks

package
v0.0.0-...-8e2590b Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package hooks provides the event system for Kairo - allowing plugins to react to app events

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Type    EventType
	Task    *core.Task             // Nil for app lifecycle events
	Patch   *core.TaskPatch        // Nil except for task_update
	Error   error                  // Nil if success
	Payload map[string]interface{} // Additional context
}

Event represents an application event that plugins can subscribe to

type EventType

type EventType string

EventType defines the type of application event

const (
	EventTaskCreate    EventType = "task_create"
	EventTaskUpdate    EventType = "task_update"
	EventTaskDelete    EventType = "task_delete"
	EventTaskDeleteAll EventType = "task_delete_all"
	EventAppStart      EventType = "app_start"
	EventAppStop       EventType = "app_stop"
)

type Listener

type Listener func(Event)

Listener is a callback that handles an event

type Manager

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

Manager manages event hooks for the application

func New

func New() *Manager

New creates a new hook manager

func (*Manager) AppStarted

func (m *Manager) AppStarted()

AppStarted emits an app startup event

func (*Manager) AppStopped

func (m *Manager) AppStopped()

AppStopped emits an app stop event

func (*Manager) Emit

func (m *Manager) Emit(event Event)

Emit triggers all listeners for an event type Listeners are called synchronously in registration order

func (*Manager) Off

func (m *Manager) Off(eventType EventType)

Off removes all listeners for an event type Note: In this implementation, we only provide removal by event type

func (*Manager) On

func (m *Manager) On(eventType EventType, listener Listener)

On registers a listener for an event type

func (*Manager) TaskCreated

func (m *Manager) TaskCreated(task core.Task)

TaskCreated emits a task creation event

func (*Manager) TaskDeleteAll

func (m *Manager) TaskDeleteAll()

TaskDeleteAll emits a bulk task deletion event

func (*Manager) TaskDeleted

func (m *Manager) TaskDeleted(taskID string)

TaskDeleted emits a task deletion event

func (*Manager) TaskUpdated

func (m *Manager) TaskUpdated(task core.Task, patch core.TaskPatch)

TaskUpdated emits a task update event

Jump to

Keyboard shortcuts

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