Documentation ¶
Overview ¶
Package lib contains convenience functionality for repeated tasks, e.g. implementing the observer pattern.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckFatal ¶
CheckFatal checks the given error, logs it in a canonical format and exists the program.
Types ¶
type ConcurrentObservable ¶
type ConcurrentObservable struct { DataLock sync.RWMutex ObserverLock sync.Mutex // contains filtered or unexported fields }
ConcurrentObservable enables KeyObservable functionality. It may be used as a mixin to enable observability.
func NewConcurrentObservable ¶
func NewConcurrentObservable() ConcurrentObservable
NewConcurrentObservable constructs a new ConcurrentObservable.
func (ConcurrentObservable) Notify ¶
func (l ConcurrentObservable) Notify(k Key)
func (ConcurrentObservable) Observe ¶
func (l ConcurrentObservable) Observe(k Key) chan bool
type KeyObservable ¶
type KeyObservable interface { // Observe registers a new observer for the given key. // The returned channel will receive a bool each time the observed key changes. Observe(k Key) chan bool // Notify notifies all registered observers of the given key of a change to the key. Notify(k Key) }
KeyObservable is a collection of key-addressable things, where each key may be observed for changes.
type PlainKey ¶
type PlainKey struct {
Text string
}
PlainKey is a box for plain strings so that they may be used as Key type.
func NewPlainKey ¶
NewPlainKey constructs a PlainKey from a plain string.
Click to show internal directories.
Click to hide internal directories.