event

package
v0.0.0-...-86833b7 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EmitterType = container.TypeOf((*Dispatcher)(nil))

Functions

func Dispatch

func Dispatch(registry *container.Registry, eventName string, event Payload) (bool, error)

func Reset

func Reset(global *container.Registry, groupName string) bool

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) Cancel

func (e *Event) Cancel()

func (*Event) CancelWithError

func (e *Event) CancelWithError(err error)

func (*Event) CancelWithErrorf

func (e *Event) CancelWithErrorf(format string, v ...interface{})

func (*Event) EventName

func (e *Event) EventName() string

func (*Event) Registry

func (e *Event) Registry() *container.Registry

func (*Event) UnSubscribe

func (e *Event) UnSubscribe()

func (*Event) WasCanceled

func (e *Event) WasCanceled() bool

type Payload

type Payload interface {
	WasCanceled() bool
	Registry() *container.Registry
	EventName() string
	Cancel()
	CancelWithError(err error)
	CancelWithErrorf(format string, v ...interface{})
	// contains filtered or unexported methods
}

type ValueEvent

type ValueEvent struct {
	*Event
	Value interface{}
}

Jump to

Keyboard shortcuts

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