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 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.