util

package module
v0.0.0-...-938d948 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2014 License: BSD-2-Clause Imports: 2 Imported by: 0

README

util

This repository contains various Go utility code.

Issues are disabled not because the code is issue free, but because I want you to fix the issue and then submit a pull request.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicObservable

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

BasicObservable implements the Observable interface, and is suitable to use as an embedded struct.

func (*BasicObservable) AddObserver

func (o *BasicObservable) AddObserver(obs Observer)

func (*BasicObservable) NotifyObservers

func (o *BasicObservable) NotifyObservers(data interface{})

func (*BasicObservable) RemoveObserver

func (o *BasicObservable) RemoveObserver(obs Observer)

type Getable

type Getable interface {
	// Should return the current value of this type
	Get() interface{}
}

Defines an interface for Getable types

type Getfunc

type Getfunc func() interface{}

type Observable

type Observable interface {
	AddObserver(Observer)
	RemoveObserver(Observer)
	NotifyObservers(data interface{})
}

A type that is observable keeps its own list of active observers which should be notified upon changes being made to this type

type Observatory

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

The Observatory type deals with connecting source and target values (via Connect) and manually polling for source value changes if needed.

Users will have to call the Update function as appropriate for polling and comparing the non-observable source values that are hooked up with the help of this Observatory.

func (*Observatory) Connect

func (o *Observatory) Connect(source, target interface{})

Connects a source value with a target value. In other words, if the source value changes, the target will be set to match.

func (*Observatory) CreateGetfunc

func (o *Observatory) CreateGetfunc(source interface{}) (get Getfunc)

Creates a function that returns the current value of the provided source parameter.

func (*Observatory) Observe

func (o *Observatory) Observe(source interface{}, get Getfunc, obsfunc Observer)

Observes a source value for changes, invoking the provided Observer upon changes. If the source is not satisfying the Observable interface, the source will be added to this Observatory's local polling list where it will use "get" and compare the returned value with a stored value copy.

func (*Observatory) Update

func (o *Observatory) Update()

Checks all poll sources for changes, and invokes the observers as needed.

type Observer

type Observer interface {
	Changed(data interface{})
}

Classic observer callback

type Setable

type Setable interface {
	// Should set the value of the current type to
	// the provided interface value.
	Set(v interface{})
}

Defines an interface for Setable types

Directories

Path Synopsis
compress
golomb
See http://en.wikipedia.org/wiki/Golomb_coding
See http://en.wikipedia.org/wiki/Golomb_coding
encoding
binary
The binary package implements code aiding in dealing with binary data.
The binary package implements code aiding in dealing with binary data.

Jump to

Keyboard shortcuts

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