local

package
v0.0.1-20220809-0001 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dispatch

func Dispatch(eventName string, dispatchData *DispatchData)

Dispatch ->

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

func RemoveListener(eventName string, id string)

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL