Browse Source

added Notifier.Close()

Darko Luketic 11 months ago
parent
commit
5e1eaa73ed
1 changed files with 6 additions and 3 deletions
  1. 6 3
      notifier.go

+ 6 - 3
notifier.go

@@ -28,14 +28,17 @@ func (n *Notifier) Listen(then func(notification *Notification)) {
 func (n *Notifier) Notify(collection, type_ string, data []byte) {
 	n.channel <- &Notification{
 		Collection: collection,
-		Type: type_,
-		Data:data,
+		Type:       type_,
+		Data:       data,
 	}
 }
 
+func (n *Notifier) Close() {
+	close(n.channel)
+}
+
 type Notification struct {
 	Collection string `json:"collection"`
 	Type       string `json:"type"`
 	Data       []byte `json:"data,omitempty"`
 }
-