Documentation ¶
Index ¶
- func Dispatch(eventName string, dispatchData *DispatchData)
- func DispatchAsync(eventName string, dispatchData *DispatchData)
- func Listen(eventName string, listenOptions *ListenOptions)
- func RemoveEvent(eventName string)
- func RemoveListener(eventName string, id string)
- type DispatchData
- type ListenOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DispatchAsync ¶
func DispatchAsync(eventName string, dispatchData *DispatchData)
DispatchAsync ->
func Listen ¶
func Listen(eventName string, listenOptions *ListenOptions)
Listen -> Start listening for an event
func RemoveEvent ¶
func RemoveEvent(eventName string)
RemoveEvent -> It will remove event entirely! (all the registered listeners will be removed) This is easier if you want to purge all listeners for an event
func RemoveListener ¶
RemoveListener -> Remove an existing listener
Types ¶
type DispatchData ¶
type DispatchData struct { Time time.Time // When it has being dispatched Id uint64 // It's optional, and sometimes it can be empty! But it can be very useful! Data interface{} EventName string // This is the event that has being dispatched }
This is the data that comes from the dispatcher
type ListenOptions ¶
type ListenOptions struct { // This is the listener name, a unique identifier, // even if the event will be recreated, it will be simply overwritten! // This param is Optional! If not defined, it will be replaced with an automated ID generator! Name string Callback func(dispatchData *DispatchData) Async bool // The callback will be run async or sync mode (goroutine or without) TTL uint64 // Time to live in the stack ExecutionPriority uint16 // This is the execution priority in the stack OnListenFailed func(err error) // This is when it has failed to listen OnEventRegisterFinish func(id string) //This is the callback which will be called when the registration will be finished! // contains filtered or unexported fields }
These are the options for listening
Click to show internal directories.
Click to hide internal directories.