comm

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2017 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package comm provides primitives for communication.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoolNotifier

type BoolNotifier interface {
	Notifier
	Value() bool
}

ColorNotifier wraps Notifier with an additional Value() method which returns a bool.

type BytesNotifier

type BytesNotifier interface {
	Notifier
	Value() []byte
}

ColorNotifier wraps Notifier with an additional Value() method which returns a []byte.

type ColorNotifier

type ColorNotifier interface {
	Notifier
	Value() color.Color
}

ColorNotifier wraps Notifier with an additional Value() method which returns a color.Color.

type DurationNotifier

type DurationNotifier interface {
	Notifier
	Value() time.Duration
}

ColorNotifier wraps Notifier with an additional Value() method which returns a time.Duration.

type Float64Notifier

type Float64Notifier interface {
	Notifier
	Value() float64
}

ColorNotifier wraps Notifier with an additional Value() method which returns a float64.

type Float64Value

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

Float64Value implements the Float64Notifier interface and a setter that updates the value and triggers notifications.

func NewFloat64Value

func NewFloat64Value(val float64) *Float64Value

Convenience function that returns a new Float64Value set to val.

func (*Float64Value) Notify

func (v *Float64Value) Notify(f func()) Id

Notify implements the Float64Notifier interface.

func (*Float64Value) SetValue

func (v *Float64Value) SetValue(val float64)

SetValue updates v.Value() and notifies any observers.

func (*Float64Value) Unnotify

func (v *Float64Value) Unnotify(id Id)

Unnotify implements the Float64Notifier interface.

func (*Float64Value) Value

func (v *Float64Value) Value() float64

Value implements the Float64Notifier interface.

type Id

type Id int64

type Int64Notifier

type Int64Notifier interface {
	Notifier
	Value() int64
}

ColorNotifier wraps Notifier with an additional Value() method which returns an int64.

type IntNotifier

type IntNotifier interface {
	Notifier
	Value() int
}

ColorNotifier wraps Notifier with an additional Value() method which returns an int.

type InterfaceNotifier

type InterfaceNotifier interface {
	Notifier
	Value() interface{}
}

ColorNotifier wraps Notifier with an additional Value() method which returns an empty interface.

type Notifier

type Notifier interface {
	Notify(f func()) Id
	Unnotify(id Id)
}

Notifier is the interface the wraps the Notify and Unnotify methods.

Notify stores the function f, and calls in the future it when the object updates. It returns an Id which can be used to stop notifications. Every call to Notify should have a corresponding Unnotify or there could be leaks.

type Relay

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

Relay implements the Notifier interface, and provides methods for triggering notifications and republishing notifications from other notifiers. It can be embeded into other structs.

func (*Relay) Notify

func (r *Relay) Notify(f func()) Id

Notify implements the Notifier interface.

func (*Relay) Signal

func (r *Relay) Signal()

Signal causes all Notifiers on r to be triggered.

func (*Relay) Subscribe

func (r *Relay) Subscribe(n Notifier)

Subscribes to notifications from n. When n posts a notification, r will also post a notification. For every Subscribe there should be a corresponding Unsubscribe or memory leaks may occur.

func (*Relay) Unnotify

func (r *Relay) Unnotify(id Id)

Unnotify implements the Notifier interface.

func (*Relay) Unsubscribe

func (r *Relay) Unsubscribe(n Notifier)

Unsubscribes from n.

type StringNotifier

type StringNotifier interface {
	Notifier
	Value() string
}

ColorNotifier wraps Notifier with an additional Value() method which returns a string.

type Uint64Notifier

type Uint64Notifier interface {
	Notifier
	Value() uint64
}

ColorNotifier wraps Notifier with an additional Value() method which returns a uint64.

type UintNotifier

type UintNotifier interface {
	Notifier
	Value() uint
}

ColorNotifier wraps Notifier with an additional Value() method which returns an uint.

Jump to

Keyboard shortcuts

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