event

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Name    string
	Payload interface{}
	Option  EventOption
}

Event structure

func NewEvent

func NewEvent(name string, payload interface{}) *Event

NewEvent create new event

func NewEventWithOption

func NewEventWithOption(name string, payload interface{}, option EventOption) *Event

NewEventWithOption create new event with option

type EventHandler

type EventHandler func(event Event)

EventHandler is a event handler function

type EventOption

type EventOption byte

EventOption is a set of event option.

func (*EventOption) AddIf

func (opts *EventOption) AddIf(opt EventOption, condition bool)

AddIf adds event option if condition is valid

func (EventOption) Has

func (opts EventOption) Has(opt EventOption) bool

Has test if event options contains this option

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager is used to handle events pub/sub

func NewEventManager

func NewEventManager() *Manager

NewEventManager creta new event manager

func (*Manager) Publish

func (m *Manager) Publish(event *Event)

Publish an event

func (*Manager) Subscribe

func (m *Manager) Subscribe(eventName string, fn EventHandler)

Subscribe an event

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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