emitter

package
v0.0.0-...-e229e0e Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2022 License: GPL-2.0 Imports: 1 Imported by: 2

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
}

func New

func New(channelSize int) *Emitter

func (*Emitter) Close

func (e *Emitter) Close()

Close - closes all channels and removes all topics

func (*Emitter) Do

func (e *Emitter) Do(topic string, event Event)

Do - writes an event to the given topic, then flushes the topic

func (*Emitter) Emit

func (e *Emitter) Emit(topic string, event Event)

Emit - writes an event to the given topic

func (*Emitter) Flush

func (e *Emitter) Flush(topic string)

Flush - flushes all events from the topic channels and calls handlers for them

func (*Emitter) FlushAll

func (e *Emitter) FlushAll()

FlushAll - flushes all events from all channels and calls handlers for them

func (*Emitter) Listeners

func (e *Emitter) Listeners(topic string) []EventChan

func (*Emitter) Off

func (e *Emitter) Off(topic string, channels ...EventChan)

func (*Emitter) On

func (e *Emitter) On(topic string, handlers ...func(Event)) EventChan

On - creates a new topic listener with optional handlers and returns the

type Event

type Event interface{}

type EventChan

type EventChan <-chan Event

type EventEmitter

type EventEmitter interface {
	On(topic string, handlers ...func(Event)) EventChan
	Off(topic string, channels ...EventChan)
	Listeners(topic string) []EventChan
	Emit(topic string, event Event)
	Do(topic string, event Event)
	Close()
	FlushAll()
	Flush(topic string)
}

Jump to

Keyboard shortcuts

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