Notify subscribers that Subscribe specified event
(eventtype EventType, value interface{})
| 71 | |
| 72 | //Notify subscribers that Subscribe specified event |
| 73 | func (e *Event) Notify(eventtype EventType, value interface{}) (err error) { |
| 74 | e.m.RLock() |
| 75 | defer e.m.RUnlock() |
| 76 | |
| 77 | subs, ok := e.subscribers[eventtype] |
| 78 | if !ok { |
| 79 | err = errors.New("No event type.") |
| 80 | return |
| 81 | } |
| 82 | |
| 83 | for _, event := range subs { |
| 84 | go e.NotifySubscriber(event, value) |
| 85 | } |
| 86 | return |
| 87 | } |
| 88 | |
| 89 | func (e *Event) NotifySubscriber(eventfunc EventFunc, value interface{}) { |
| 90 | if eventfunc == nil { |