| 1 | package observer |
| 2 | |
| 3 | type state struct { |
| 4 | value interface{} |
| 5 | next *state |
| 6 | done chan struct{} |
| 7 | } |
| 8 | |
| 9 | func newState(value interface{}) *state { |
| 10 | return &state{ |
| 11 | value: value, |
| 12 | done: make(chan struct{}), |
| 13 | } |
| 14 | } |
| 15 | |
| 16 | func (s *state) update(value interface{}) *state { |
| 17 | s.next = newState(value) |
| 18 | close(s.done) |
| 19 | return s.next |
| 20 | } |