Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Observer ¶
type Observer interface {
OnUpdate(msg string)
}
Example ¶
weather := NewSubject() joe := NewObserver("joe") weather.attach(joe) tom := NewObserver("tom") weather.attach(tom) weather.notify("today is sunshiny") fmt.Println("---") weather.detach(joe) weather.notify("tomorrow is cloudy") fmt.Println("---") weather.detach(tom) weather.notify("oh my god")
Output: joe: received "today is sunshiny" tom: received "today is sunshiny" --- tom: received "tomorrow is cloudy" ---
func NewObserver ¶
type Subject ¶
type Subject interface {
// contains filtered or unexported methods
}
func NewSubject ¶
func NewSubject() Subject
Click to show internal directories.
Click to hide internal directories.