emitter

package
v0.0.0-...-5b28944 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: Apache-2.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 Emitter

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

Emitter exposes an EventEmitter-like interface

func NewEmitter

func NewEmitter() Emitter

NewEmitter initializes an Emitter

func (*Emitter) Emit

func (p *Emitter) Emit(event string, data interface{})

Emit emits an event with contextual data

func (*Emitter) Off

func (p *Emitter) Off(event string, handler EventHandler)

Off remove a listener function, pointer of the function passed must match with the one

func (*Emitter) On

func (p *Emitter) On(event string, handler EventHandler)

On register a function. Note that the pointer to the function need to be the same to be removed with Off

type EventHandler

type EventHandler func(interface{})

EventHandler wrap an event callback

Jump to

Keyboard shortcuts

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