diff --git a/README.md b/README.md index 08c5c4f..8104aaf 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ go func() { }() time.Sleep(5 * time.Second) -close(unsub) +unsub() ``` ### Publishing an event diff --git a/relaypool.go b/relaypool.go index 57033e5..5c15b2f 100644 --- a/relaypool.go +++ b/relaypool.go @@ -124,7 +124,7 @@ func (r *RelayPool) Remove(url string) { } } -func (r *RelayPool) Sub(filters Filters) (string, chan EventMessage, chan struct{}) { +func (r *RelayPool) Sub(filters Filters) (string, chan EventMessage, func()) { random := make([]byte, 7) rand.Read(random) id := hex.EncodeToString(random) @@ -154,7 +154,7 @@ func (r *RelayPool) Sub(filters Filters) (string, chan EventMessage, chan struct return true }) - return id, eventStream, unsub + return id, eventStream, func() { close(unsub) } } func Unique(all chan EventMessage) chan Event {