subscribe on all events if no events type are given
This commit is contained in:
parent
49708ed503
commit
075a8441cd
@ -16,6 +16,7 @@ func (i *Client) Subscribe(ctx context.Context, events ...EventType) (<-chan Eve
|
||||
|
||||
out := make(chan Event, 10)
|
||||
eventMap := slices.ToStructMap(events)
|
||||
allEvents := len(events) == 0
|
||||
|
||||
go func() {
|
||||
defer r.Close()
|
||||
@ -25,7 +26,7 @@ func (i *Client) Subscribe(ctx context.Context, events ...EventType) (<-chan Eve
|
||||
|
||||
for ctx.Err() == nil && sc.Scan() {
|
||||
event := parseEvent(sc.Text())
|
||||
if _, ok := eventMap[event.Type]; ok {
|
||||
if _, ok := eventMap[event.Type]; allEvents || ok {
|
||||
out <- event
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user