dispatcher

package
v0.0.0-...-ce4c9c0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2021 License: BSD-2-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dispatcher

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

Dispatcher implements an event dispatcher.

func NewDispatcher

func NewDispatcher() *Dispatcher

NewDispatcher creates and returns a new event dispatcher.

func (*Dispatcher) Dispatch

func (d *Dispatcher) Dispatch(evname eventtype.EventType, ev interface{}) int

Dispatch dispatches the specified event to all registered subscribers. The function returns the number of subscribers to which the event was dispatched.

func (*Dispatcher) Initialize

func (d *Dispatcher) Initialize()

Initialize initializes the event dispatcher. It is normally used by other types which embed a dispatcher.

func (*Dispatcher) Subscribe

func (d *Dispatcher) Subscribe(evname eventtype.EventType, callBack dispatcheri.Callback)

Subscribe subscribes a callback to events with the given name. If it is necessary to unsubscribe later, SubscribeID should be used instead.

func (*Dispatcher) SubscribeID

func (d *Dispatcher) SubscribeID(evname eventtype.EventType, id interface{}, callBack dispatcheri.Callback)

SubscribeID subscribes a callback to events events with the given name. The user-provided unique id can be used to unsubscribe via UnsubscribeID.

func (*Dispatcher) UnsubscribeAllID

func (d *Dispatcher) UnsubscribeAllID(id interface{}) int

UnsubscribeAllID removes all subscribed callbacks with the specified unique id from all events. Returns the number of subscriptions removed.

func (*Dispatcher) UnsubscribeID

func (d *Dispatcher) UnsubscribeID(evname eventtype.EventType, id interface{}) int

UnsubscribeID removes all subscribed callbacks with the specified unique id

from the specified event.

Returns the number of subscriptions removed.

Jump to

Keyboard shortcuts

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