ebus

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2021 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataEvent

type DataEvent struct {
	Data  interface{}
	Topic string
}

DataEvent represents an event posted to a topic.

type EventBus

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

EventBus stores the information about subscribers interested for a particular topic.

func Instance

func Instance() *EventBus

Instance creates an single EventBus instance.

func NewEventBus

func NewEventBus() *EventBus

NewEventBus creates an EventBus instance.

func (*EventBus) Publish

func (eb *EventBus) Publish(topic string, data interface{})

Publish publishes data in the topic provided.

func (*EventBus) Subscribe

func (eb *EventBus) Subscribe(topic string) *Subscription

Subscribe to the topic provided to receive data events.

type Subscription

type Subscription struct {
	Event       <-chan DataEvent
	Unsubscribe func()
}

Subscription represents a subscription to a topic.

Jump to

Keyboard shortcuts

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