v0.0.1 Latest Latest

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

Go to latest
Published: Jan 25, 2016 License: GPL-3.0 Imports: 5 Imported by: 27



Package event implements an event multiplexer.



This section is empty.


View Source
var ErrMuxClosed = errors.New("event: mux closed")

ErrMuxClosed is returned when Posting on a closed TypeMux.


This section is empty.


type Event

type Event struct {
	Time time.Time
	Data interface{}

Event is a time-tagged notification pushed to subscribers.

type Subscription

type Subscription interface {
	// Chan returns a channel that carries events.
	// Implementations should return the same channel
	// for any subsequent calls to Chan.
	Chan() <-chan *Event

	// Unsubscribe stops delivery of events to a subscription.
	// The event channel is closed.
	// Unsubscribe can be called more than once.

Subscription is implemented by event subscriptions.

type TypeMux

type TypeMux struct {
	// contains filtered or unexported fields

A TypeMux dispatches events to registered receivers. Receivers can be registered to handle events of certain type. Any operation called after mux is stopped will return ErrMuxClosed.

The zero value is ready to use.

func (*TypeMux) Post

func (mux *TypeMux) Post(ev interface{}) error

Post sends an event to all receivers registered for the given type. It returns ErrMuxClosed if the mux has been stopped.

func (*TypeMux) Stop

func (mux *TypeMux) Stop()

Stop closes a mux. The mux can no longer be used. Future Post calls will fail with ErrMuxClosed. Stop blocks until all current deliveries have finished.

func (*TypeMux) Subscribe

func (mux *TypeMux) Subscribe(types ...interface{}) Subscription

Subscribe creates a subscription for events of the given types. The subscription's channel is closed when it is unsubscribed or the mux is closed.


Path Synopsis
Package filter implements event filters.
Package filter implements event filters.

Jump to

Keyboard shortcuts

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