Documentation
¶
Overview ¶
Package observer is an example of the Observer Pattern. Push model.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConcreteObserver ¶
type ConcreteObserver struct {
// contains filtered or unexported fields
}
ConcreteObserver implements the Observer interface.
func (*ConcreteObserver) Update ¶
func (s *ConcreteObserver) Update(state string)
Update set new state
type ConcretePublisher ¶
type ConcretePublisher struct {
// contains filtered or unexported fields
}
ConcretePublisher implements the Publisher interface.
func (*ConcretePublisher) Attach ¶
func (s *ConcretePublisher) Attach(observer Observer)
Attach a Observer
func (*ConcretePublisher) Notify ¶
func (s *ConcretePublisher) Notify()
Notify sends notifications to subscribers. Push model.
func (*ConcretePublisher) SetState ¶
func (s *ConcretePublisher) SetState(state string)
SetState sets new state
type Observer ¶
type Observer interface {
Update(state string)
}
Observer provides a subscriber interface.
Example ¶
publisher := NewPublisher()
publisher.Attach(&ConcreteObserver{})
publisher.Attach(&ConcreteObserver{})
publisher.Attach(&ConcreteObserver{})
publisher.SetState("New State...")
publisher.Notify()
Click to show internal directories.
Click to hide internal directories.