Skip to content

Commit 4aea323

Browse files
author
xiyuliu
committed
[refactor] use AddEventListener check instead of OnMessage check
1 parent 0aad9f4 commit 4aea323

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sse.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,8 @@ func (es *EventSource) Get() error {
368368
es.method = defaultHTTPMethod
369369
}
370370

371-
if _, found := es.onEvent[defaultEventName]; !found {
372-
return fmt.Errorf("resty:sse: OnMessage function is required")
371+
if len(es.onEvent) == 0 {
372+
return fmt.Errorf("resty:sse: At least one OnMessage/AddEventListener func is required")
373373
}
374374

375375
// reset to begin

0 commit comments

Comments
 (0)