events

package
v0.5.10 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package events provides a simple abstraction layer for producing and consuming in-process events.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event interface{}

Event is an interface to allow any kind of message to be produced to Watchers.

type Manager

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

Manager is the type used to allow registration of watchers interested in certain kinds of events.

func (*Manager) Emit

func (m *Manager) Emit(event Event)

Emit will send an Event out to all Watchers registered to listen for Events.

func (*Manager) Stop

func (m *Manager) Stop(watcher *Watcher)

Stop will unregister a Watcher and close its Ch channel.

func (*Manager) Watch

func (m *Manager) Watch() *Watcher

Watch will create a new Watcher that can be used to wait for Events to be emitted.

type Watcher

type Watcher struct {
	Ch chan Event
	// contains filtered or unexported fields
}

Watcher is the type used to process Events that have been emitted on the Ch channel.

func (*Watcher) Stop

func (w *Watcher) Stop()

Stop will unregister a Watcher and close its Ch channel.

Jump to

Keyboard shortcuts

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