Documentation
¶
Overview ¶
Package eventbus 事件总线(泛型版)
Index ¶
- func Publish[T any](arg T, ebs ...*Eventbus) error
- func Subscribe[T any](f func(arg T), ebs ...*Eventbus) error
- func SubscribeWithErr[T any](f func(arg T) error, ebs ...*Eventbus) error
- func UnSubscribe[T any](f func(arg T), ebs ...*Eventbus)
- func UnSubscribeType[T any](ebs ...*Eventbus)
- func UnSubscribeWithErr[T any](f func(arg T) error, ebs ...*Eventbus)
- type Eventbus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SubscribeWithErr ¶
SubscribeWithErr 订阅事件
事件响应时,不带错误返回的函数全部会被调用,带错误返回的函数执行到第一个出错函数结束,并返回第一个出错函数的返回值
func UnSubscribeWithErr ¶
UnSubscribeWithErr 取消订阅事件
Types ¶
type Eventbus ¶
type Eventbus struct {
// contains filtered or unexported fields
}
Eventbus 事件总线,为业务提供通用的事件订阅、发布机制,降低业务模块间的耦合
func DefaultEventBus ¶
func DefaultEventBus() *Eventbus
Click to show internal directories.
Click to hide internal directories.