flowutil

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2022 License: CC0-1.0 Imports: 1 Imported by: 1

Documentation

Overview

Package flowutil contains utilities to manage control flow.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventCallback

type EventCallback func(event string, eventSource interface{})

EventCallback is the callback function which is called when an event was observed.

type EventPump

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

EventPump implements the observer pattern. Observers can subscribe to receive notifications on certain events. Observed objects can send notifications.

func NewEventPump

func NewEventPump() *EventPump

NewEventPump creates a new event pump.

func (*EventPump) AddObserver

func (ep *EventPump) AddObserver(event string, eventSource interface{}, callback EventCallback)

AddObserver adds a new observer to the event pump. An observer can subscribe to a given event from a given event source. If the event is an empty string then the observer subscribes to all events from the event source. If the eventSource is nil then the observer subscribes to all event sources.

func (*EventPump) PostEvent

func (ep *EventPump) PostEvent(event string, eventSource interface{})

PostEvent posts an event to this event pump from a given event source.

func (*EventPump) RemoveObservers

func (ep *EventPump) RemoveObservers(event string, eventSource interface{})

RemoveObservers removes observers from the event pump. If the event is an empty string then the observer is removed from all events. If the eventSource is nil then all observers of the event are dropped.

Jump to

Keyboard shortcuts

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