events

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event interface {
	// GetType returns the type of the event
	GetType() Type

	// GetData returns the wrapped event data
	GetData() any
}

Event is the abstraction for any event

type Manager

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

Manager is the subscription manager

func NewManager

func NewManager() *Manager

NewManager creates a new instance of the subscription manager

func (*Manager) CancelSubscription

func (em *Manager) CancelSubscription(id SubscriptionID)

CancelSubscription stops a subscription for events

func (*Manager) Close

func (em *Manager) Close()

Close stops the event manager, effectively cancelling all subscriptions

func (*Manager) SignalEvent

func (em *Manager) SignalEvent(event Event)

SignalEvent is a helper method for alerting listeners of a new message event

func (*Manager) Subscribe

func (em *Manager) Subscribe(eventTypes []Type) *Subscription

Subscribe registers a new listener for events

type Subscription

type Subscription struct {
	// SubCh is the notification channel
	// on which the listener will receive notifications
	SubCh chan Event

	// ID is the unique identifier of the subscription
	ID SubscriptionID
}

Subscription is the subscription returned to the user

type SubscriptionID

type SubscriptionID int32

type Type

type Type string

Jump to

Keyboard shortcuts

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