8000 GitHub - bruceesmith/observable: Package observable is an implementation of the Gang of Four Observer pattern
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

bruceesmith/observable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Reference Go Report Card

observable

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.

Index

func Observe

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

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

About

Package observable is an implementation of the Gang of Four Observer pattern

Resources

License

Stars

Watchers

Forks

Packages

No packages published
0