events

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2019 License: Apache-2.0 Imports: 1 Imported by: 1

Documentation

Overview

events defines an event subscriber and dispatcher

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EmitterInterface

type EmitterInterface interface {
	// Emit Sends an event to the subscribed listeners
	Emit(Event)

	// Subscribe Registers a callback that will receive emitted events
	Subscribe(context.Context, func(Event))

	// UnsubscribeAll removes all listeners
	UnsubscribeAll()
}

EmitterInterface Root interface for events dispatch

type Event

type Event interface{}

Event Is a base interface for events

type EventEmitter

type EventEmitter struct {
	Subscribers []*eventSubscription
}

EventEmitter Registers listeners and dispatches events to them

func (*EventEmitter) Emit

func (e *EventEmitter) Emit(evt Event)

func (*EventEmitter) Subscribe

func (e *EventEmitter) Subscribe(ctx context.Context, handler func(Event))

func (*EventEmitter) UnsubscribeAll

func (e *EventEmitter) UnsubscribeAll()

Jump to

Keyboard shortcuts

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