Documentation ¶
Index ¶
- Variables
- func Dispatch(registry *container.Registry, eventName string, event Payload) (bool, error)
- func Reset(global *container.Registry, groupName string) bool
- type Dispatcher
- func (dispatcher *Dispatcher) Dispatch(registry *container.Registry, eventName string, event Payload) (bool, error)
- func (dispatcher *Dispatcher) Inherit() *Dispatcher
- func (dispatcher *Dispatcher) Reset(groupName string) bool
- func (dispatcher *Dispatcher) Subscribe(events string, handler interface{}) *Dispatcher
- type Event
- type Payload
- type ValueEvent
Constants ¶
This section is empty.
Variables ¶
View Source
var EmitterType = container.TypeOf((*Dispatcher)(nil))
Functions ¶
Types ¶
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
func GetDispatcher ¶
func GetDispatcher(c *container.Registry) *Dispatcher
func NewDispatcher ¶
func NewDispatcher() *Dispatcher
func Subscribe ¶
func Subscribe(global *container.Registry, groupName string, handler interface{}) *Dispatcher
func (*Dispatcher) Dispatch ¶
func (dispatcher *Dispatcher) Dispatch(registry *container.Registry, eventName string, event Payload) (bool, error)
Dispatch emits an event in the given eventName with the specified key, calling *Event.Cancel() will stop the event propagation, calling *Event.CancelWithError(err) will flag an error and cancel the event propagation
func (*Dispatcher) Inherit ¶
func (dispatcher *Dispatcher) Inherit() *Dispatcher
func (*Dispatcher) Reset ¶
func (dispatcher *Dispatcher) Reset(groupName string) bool
func (*Dispatcher) Subscribe ¶
func (dispatcher *Dispatcher) Subscribe(events string, handler interface{}) *Dispatcher
Subscribe an event eventName, you can subscribe to multiple event groups by separating eventName names with | example "group1|group2" will subscribe group1 and group2, take per example app.run and app.run.tls
subscribing to app.run event groups with be as simples as app.Subscribe("app.run|app.run.tls",func(e *event.Event,a *app.App){ println("App is starting a server ", e.EventName()) })
type Event ¶
type Event struct {
// contains filtered or unexported fields
}
func (*Event) CancelWithError ¶
func (*Event) CancelWithErrorf ¶
func (*Event) UnSubscribe ¶
func (e *Event) UnSubscribe()
func (*Event) WasCanceled ¶
type ValueEvent ¶
type ValueEvent struct { *Event Value interface{} }
Click to show internal directories.
Click to hide internal directories.