event

package
v1.0.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetEventName

func GetEventName(event Event) string

GetEventName 获取事件名称

Types

type BaseEvent

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

BaseEvent 基础事件

func NewBaseEvent

func NewBaseEvent(name string) BaseEvent

NewBaseEvent 创建基础事件

func (BaseEvent) Data

func (e BaseEvent) Data() interface{}

Data 获取事件数据

func (BaseEvent) Name

func (e BaseEvent) Name() string

Name 获取事件名称

type Dispatcher

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

Dispatcher 事件分发器

func NewDispatcher

func NewDispatcher() *Dispatcher

NewDispatcher 创建事件分发器

func (*Dispatcher) Dispatch

func (d *Dispatcher) Dispatch(event Event)

Dispatch 分发事件

func (*Dispatcher) DispatchSync

func (d *Dispatcher) DispatchSync(event Event)

DispatchSync 同步分发事件

func (*Dispatcher) Flush

func (d *Dispatcher) Flush()

Flush 清除所有监听器

func (*Dispatcher) Forget

func (d *Dispatcher) Forget(eventName string)

Forget 移除事件监听器

func (*Dispatcher) HasListeners

func (d *Dispatcher) HasListeners(eventName string) bool

HasListeners 检查是否有监听器

func (*Dispatcher) Listen

func (d *Dispatcher) Listen(eventName string, listener Listener)

Listen 注册事件监听器

type Event

type Event interface {
	Name() string
	Data() interface{}
}

Event 事件接口

type Listener

type Listener func(event Event)

Listener 事件监听器

type Subscribe

type Subscribe interface {
	Subscribe() map[string][]Listener
}

Subscribe 订阅者接口

Jump to

Keyboard shortcuts

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