events

package
v0.0.0-...-1568502 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CallbackPool

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

func (*CallbackPool) Add

func (cp *CallbackPool) Add(callback *func(Event))

Pushes a new callback into the array of listeners for the pool.

func (*CallbackPool) Remove

func (cp *CallbackPool) Remove(callback *func(Event))

Removes a callback from the array of registered callbacks if it exists.

type Event

type Event struct {
	Data  string
	Topic string
}

type EventBus

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

func New

func New() *EventBus

func (*EventBus) Destroy

func (e *EventBus) Destroy()

Removes all of the event listeners that have been registered for any topic. Also stops the worker pool to close that routine.

func (*EventBus) Off

func (e *EventBus) Off(topic string, callback *func(Event))

Removes an event listener from the bus.

func (*EventBus) On

func (e *EventBus) On(topic string, callback *func(Event))

Register a callback function that will be executed each time one of the events using the topic name is called.

func (*EventBus) Publish

func (e *EventBus) Publish(topic string, data string)

Publish data to a given topic.

func (*EventBus) PublishJson

func (e *EventBus) PublishJson(topic string, data interface{}) error

Publishes a JSON message to a given topic.

Jump to

Keyboard shortcuts

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