observer

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: MIT Imports: 2 Imported by: 1

Documentation

Overview

Package observer provides an observer implementation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Key

type Key generic.Type

Key is the type used for ginny to generate generics.

type KeyObserver deprecated

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

KeyObserver implements an event manager that allows us to add/remove listeners at will listeners can be added on an event "e" and pass a channel in. Every time an event "e" is emitted, all listeners listening on channel "e" will receive that event. see https://flaviocopes.com/golang-event-listeners/ for details.

Deprecated: this should be replaced by ethereums's event subscription: https://pkg.go.dev/github.com/ethereum/go-ethereum@v1.10.5/event#Subscription

func NewKeyObserver

func NewKeyObserver() *KeyObserver

NewKeyObserver creates a new observer.

func (*KeyObserver) AddListener

func (b *KeyObserver) AddListener(e Key, ch chan interface{})

AddListener adds an event listener to the KeyObserver struct instance. This listener will receive all events on event "e" on channel "ch".

func (*KeyObserver) Emit

func (b *KeyObserver) Emit(e Key, response interface{})

Emit emits an event on the KeyObserver struct instance. The event is received by all listeners listening on event.

func (*KeyObserver) RemoveListener

func (b *KeyObserver) RemoveListener(e Key, ch chan interface{})

RemoveListener removes an event listener from the KeyObserver struct instance. Note: listeners must be removed before the channel is closed to prevent a race condition.

type StringObserver deprecated

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

StringObserver implements an event manager that allows us to add/remove listeners at will listeners can be added on an event "e" and pass a channel in. Every time an event "e" is emitted, all listeners listening on channel "e" will receive that event. see https://flaviocopes.com/golang-event-listeners/ for details.

Deprecated: this should be replaced by ethereums's event subscription: https://pkg.go.dev/github.com/ethereum/go-ethereum@v1.10.5/event#Subscription

func NewStringObserver

func NewStringObserver() *StringObserver

NewStringObserver creates a new observer.

func (*StringObserver) AddListener

func (b *StringObserver) AddListener(e string, ch chan interface{})

AddListener adds an event listener to the StringObserver struct instance. This listener will receive all events on event "e" on channel "ch".

func (*StringObserver) Emit

func (b *StringObserver) Emit(e string, response interface{})

Emit emits an event on the StringObserver struct instance. The event is received by all listeners listening on event.

func (*StringObserver) RemoveListener

func (b *StringObserver) RemoveListener(e string, ch chan interface{})

RemoveListener removes an event listener from the StringObserver struct instance. Note: listeners must be removed before the channel is closed to prevent a race condition.

Jump to

Keyboard shortcuts

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