From 36758293ce24d49e98efca5bb084ea302204defd Mon Sep 17 00:00:00 2001 From: recursive-franciscop Date: Wed, 27 Nov 2024 14:47:29 +0900 Subject: [PATCH] Allow for both sync and async methods --- src/fetch.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fetch.ts b/src/fetch.ts index 162ea45..3a468b9 100644 --- a/src/fetch.ts +++ b/src/fetch.ts @@ -16,20 +16,20 @@ export interface FetchEventSourceInit extends RequestInit { * actually matches what you expect (and throw if it doesn't.) If not provided, * will default to a basic validation to ensure the content-type is text/event-stream. */ - onopen?: (response: Response) => Promise, + onopen?: (response: Response) => void | Promise; /** * Called when a message is received. NOTE: Unlike the default browser * EventSource.onmessage, this callback is called for _all_ events, * even ones with a custom `event` field. */ - onmessage?: (ev: EventSourceMessage) => void; + onmessage?: (ev: EventSourceMessage) => void | Promise; /** * Called when a response finishes. If you don't expect the server to kill * the connection, you can throw an exception here and retry using onerror. */ - onclose?: () => void; + onclose?: () => void | Promise; /** * Called when there is any error making the request / processing messages /