eventemitter

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventData

type EventData any

EventData is a generic event data can be typed and registered with tendermint/go-amino via concrete implementation of this interface.

type EventEmitter

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

EventEmitter is a simple implementation of event emitter, where listeners subscribe to certain events and, when an event is emitted (see Emitter), notified via a callback function

func New

func New(opts ...OptionFunc) *EventEmitter

New creates and returns a new event emitter instance

func (*EventEmitter) AddListener

func (e *EventEmitter) AddListener(event string, listener ListenerFunc)

AddListener adds a listener function to the event set, that will be called during Emit operation

func (*EventEmitter) Emit

func (e *EventEmitter) Emit(event string, data EventData)

Emit synchronously invokes all registered listeners for the given event name and data

type ListenerFunc

type ListenerFunc func(data EventData) error

ListenerFunc is a type function of an event listener

type OptionFunc

type OptionFunc func(*EventEmitter)

OptionFunc is an option function to be able to set custom values to event emitter

func WithLogger

func WithLogger(logger log.Logger) OptionFunc

WithLogger sets logger to event emitter

type Subscriber

type Subscriber interface {
	Subscribe(emitter *EventEmitter)
}

Subscriber is the interface reactors and other modules must export to become eventable.

Jump to

Keyboard shortcuts

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