Documentation ¶
Index ¶
Constants ¶
View Source
const ( // EHANDLE_OK means that the event should not be cancelled. EHANDLE_OK = 0 // EHANDLE_CANCEL means that the event should be cancelled. EHANDLE_CANCEL = 1 )
View Source
const ( // EFLAG_NORMAL means this is a normal sync event. EFLAG_NORMAL = 0 // EFLAG_UNCANCELLABLE means that the event cannot be cancelled. EFLAG_UNCANCELLABLE = 1 << 0 // EFLAG_ASYNC_UNSAFE means that the event is an async event. Don't use declaritvely. EFLAG_ASYNC_UNSAFE = 1 << 1 // Don't use this directly! // EFLAG_ASYNC means thtat the event will be processed asychronously. EFLAG_ASYNC = EFLAG_ASYNC_UNSAFE | EFLAG_UNCANCELLABLE )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventBus ¶
type EventBus struct {
// contains filtered or unexported fields
}
An EventBus takes events and forwards them to event handlers matched by name.
func NewEventBus ¶
func NewEventBus() EventBus
NewEventBus creates a new event bus without any event handlers.
func (*EventBus) CountHandlers ¶
CountHandlers is a convenience function.
func (*EventBus) PublishNonblocking ¶
PublishNonblocking sends async events off to the relevant handlers witout blocking.
func (*EventBus) RegisterHandler ¶
func (b *EventBus) RegisterHandler(eventName string, hFunc func(Event) EventHandleResult)
RegisterHandler registers an event handler function by name
type EventHandleResult ¶
type EventHandleResult uint8
EventHandleResult is a flag field to represent certain things.
Click to show internal directories.
Click to hide internal directories.