Documentation
¶
Index ¶
- func DisposeHandler()
- func RegisterHandler(handlers map[string]Handler)
- type Dispatcher
- func (dispatcher *Dispatcher) Dispatch(params ...interface{}) (err error)
- func (dispatcher *Dispatcher) Dispose()
- func (dispatcher *Dispatcher) Off(event *Event)
- func (dispatcher *Dispatcher) OffAll()
- func (dispatcher *Dispatcher) On(handler Handler, priority int, params ...interface{}) (event *Event)
- func (dispatcher *Dispatcher) OnKey(handlerKey string, priority int, params ...interface{}) (event *Event)
- func (dispatcher *Dispatcher) Once(handler Handler, priority int, params ...interface{}) (event *Event)
- type Event
- type Handler
- type IDispatcher
- type IEvent
- type IHandler
- type Manager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DisposeHandler ¶
func DisposeHandler()
func RegisterHandler ¶
Types ¶
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
func GetEvent ¶
func GetEvent(event string) *Dispatcher
func (*Dispatcher) Dispatch ¶
func (dispatcher *Dispatcher) Dispatch(params ...interface{}) (err error)
Dispatch / 派发消息,实现了冒泡
func (*Dispatcher) Dispose ¶
func (dispatcher *Dispatcher) Dispose()
func (*Dispatcher) Off ¶
func (dispatcher *Dispatcher) Off(event *Event)
func (*Dispatcher) OffAll ¶
func (dispatcher *Dispatcher) OffAll()
func (*Dispatcher) On ¶
func (dispatcher *Dispatcher) On(handler Handler, priority int, params ...interface{}) (event *Event)
On 添加类型为[type],处理方法为[handler]的监听器,优先级[priority]的数值越大,越早触发 返回event用于避免重复监听
type Event ¶
type Event struct { // 监听时赋予的参数 OnParams []interface{} // 触发时赋予的参数 DispatchParams []interface{} // 事件的类型 Kind string // contains filtered or unexported fields }
type IDispatcher ¶
type IDispatcher interface { Dispose() Wait(kind string, params ...interface{}) IEvent OnKey(kind string, handlerKey string, priority int, params ...interface{}) On(kind string, handler IHandler, priority int, params ...interface{}) Once(kind string, handler IHandler, priority int, params ...interface{}) Off(kind string, handler IHandler) OffAll() OffKind(kind string) Dispatch(kind string, params ...interface{}) // contains filtered or unexported methods }
type Manager ¶
func NewManager ¶
func NewManager(host interface{}) (obj *Manager)
func (*Manager) GetDispatcher ¶
func (mgr *Manager) GetDispatcher(event string) *Dispatcher
Click to show internal directories.
Click to hide internal directories.