events

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2022 License: Apache-2.0 Imports: 3 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event interface {
	Topic() string
	Message() interface{}
}

type EventService

type EventService interface {
	GetPublisher() Publisher
	GetSubscriber() Subscriber
}

type EventSystem

type EventSystem interface {
	Subscriber
	Publisher
}

type Listener

type Listener interface {
	OnReceive(event Event)
}

type Publisher

type Publisher interface {
	Publish(event Event)
}

func GetPublisher

func GetPublisher(sp view.ServiceProvider) (Publisher, error)

type Service

type Service struct {
	EventSystem EventSystem
}

func (*Service) GetPublisher

func (s *Service) GetPublisher() Publisher

func (*Service) GetSubscriber

func (s *Service) GetSubscriber() Subscriber

type Subscriber

type Subscriber interface {
	Subscribe(topic string, receiver Listener)
	Unsubscribe(topic string, receiver Listener)
}

func GetSubscriber

func GetSubscriber(sp view.ServiceProvider) (Subscriber, error)

type Subscribers

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

Subscribers is a thread-safe map of subscribers. It is used to keep track of bindings between wrapped listeners and their wrappers.

func NewSubscribers

func NewSubscribers() *Subscribers

NewSubscribers returns a new instance of Subscribers.

func (*Subscribers) Delete

func (s *Subscribers) Delete(id string, wrapped interface{})

Delete removes the binding for the given id and wrapped listener

func (*Subscribers) Get

func (s *Subscribers) Get(id string, wrapped interface{}) (interface{}, bool)

Get returns the wrapper listener for the given id and wrapped listener.

func (*Subscribers) Set

func (s *Subscribers) Set(id string, wrapped, wrapper interface{})

Set sets a new binding between a wrapped listener and its wrapper. The binding is indexed by the passed id.

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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