Emitter

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Dump from https://github.com/moleculer-go/goemitter/blob/master/goemitter.go

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 - our listeners container

func Construct

func Construct() *Emitter

Construct() - create a new instance of Emitter

func (*Emitter) AddListener

func (emitter *Emitter) AddListener(event string, callback func(...interface{})) *Emitter

AddListener() - register a new listener on the specified event

func (*Emitter) Destruct

func (emitter *Emitter) Destruct()

Destruct() - free memory from an emitter instance

func (*Emitter) EmitAsync

func (emitter *Emitter) EmitAsync(event string, args []interface{}) *Emitter

EmitAsync() - run all listeners of the specified event in asynchronous mode using goroutines

func (*Emitter) EmitSync

func (emitter *Emitter) EmitSync(event string, args ...interface{}) *Emitter

EmitSync() - run all listeners of the specified event in synchronous mode

func (*Emitter) Listeners

func (emitter *Emitter) Listeners(event string) []Listener

Listeners() - return an array with the registered listeners in the specified event

func (*Emitter) ListenersCount

func (emitter *Emitter) ListenersCount(event string) int

ListenersCount() - return the count of listeners in the speicifed event

func (*Emitter) On

func (emitter *Emitter) On(event string, callback func(...interface{})) *Emitter

On() - register a new listener on the specified event

func (*Emitter) Once

func (emitter *Emitter) Once(event string, callback func(...interface{})) *Emitter

Once() - register a new one-time listener on the specified event

func (*Emitter) RemoveAllListeners

func (emitter *Emitter) RemoveAllListeners(event interface{}) *Emitter

RemoveAllListeners() - remove all listeners from (all/event)

func (*Emitter) RemoveListener

func (emitter *Emitter) RemoveListener(event string, callback func(...interface{})) *Emitter

RemoveListeners() - remove the specified callback from the specified events' listeners

type Listener

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

Listener - our callback container and whether it will run once or not

Jump to

Keyboard shortcuts

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