observer

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2017 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ObserverValueChanged = "Value Changed"
)

Variables

View Source
var ObserverRefreshTime = 100 * time.Millisecond

ObserverRefreshTime defines how often the routinge of the observer checks for changes.

Functions

This section is empty.

Types

type EventFunc

type EventFunc func(event string, sv chan stringValue)

EventFunc is used to define a function which is called when a value changes

type Observer

type Observer struct {
	RefreshTime time.Duration
	// contains filtered or unexported fields
}

Observer watches variables if they change

func NewObserver

func NewObserver() *Observer

NewObserver creates a empty Observer

func (*Observer) AddString

func (o *Observer) AddString(key string, s *string)

AddString to the observer. The key is used to identify that variable, when a event emitts data

func (*Observer) Start

func (o *Observer) Start()

Start to begin watching the varaibles

func (*Observer) Stop

func (o *Observer) Stop()

Stop the observer watching the variables

func (*Observer) Subscribe

func (o *Observer) Subscribe(svc chan stringValue)

Subscribe a func type EventFunc to the observer. All subscribed functions are called, when a event happens

Jump to

Keyboard shortcuts

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