import "github.com/bruceesmith/observable"
Package observable is a simple generic implementation of the Gang of Four Observer design pattern, useful in event-driven programs such as GUIs.
Observables are identified by a string name which must be unique across an application. Calling the Observe function both registers an observable by name and type, but also registers an observer by providing a notification function that is invoked when the value of the observable changes. Multiple observers can call Observe to register for notifications concerning an existing observable; in this case, notification functions are called in the order in which they were registered.
To change the value of an observable, and to notify all observers by invoking their callback notification function, call the Set function.
func Observe[T any](name string, cb func(T)) error
Observe either registers a new observable, or adds another observer (notification function) to an existing observable
func Set[T any](name string, value T) error
Set notifies all observers that the value of an observable has changed by calling all registered notification functions
Generated by gomarkdoc