Skip to content

Commit

Permalink
return the StreamClient from StreamClient.start so we can chain it
Browse files Browse the repository at this point in the history
  • Loading branch information
ptpaterson committed Mar 6, 2024
1 parent 2902dc6 commit 8e0bd6d
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -643,12 +643,10 @@ export class StreamClient {
this.#httpStreamClient = httpStreamClient;
}

on(type: StreamEventType, callback: StreamEventHandler) {
this.#callbacks[type].push(callback);
return this;
}

start(onEvent: StreamEventHandler, onFatalError?: (error: Error) => void) {
start(
onEvent: StreamEventHandler,
onFatalError: (error: Error) => void
): StreamClient {
if (typeof onEvent !== "function") {
throw new TypeError(
`Expected a function as the 'onEvent' argument, but received ${typeof onEvent}. Please provide a valid function.`
Expand All @@ -671,6 +669,7 @@ export class StreamClient {
}
};
run();
return this;
}

async *[Symbol.asyncIterator](): AsyncGenerator<StreamEvent> {
Expand Down

0 comments on commit 8e0bd6d

Please sign in to comment.