Skip to content

Commit 1183fed

Browse files
andywerabuiles
authored andcommitted
Fix CallBuilder onmessage type (#385)
We don't pass the MessageEvent to the callback, but take the data out of it and `JSON.parse()` it before we pass it on.
1 parent c577039 commit 1183fed

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/call_builder.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ const version = require("../package.json").version;
1212

1313
type Constructable<T> = new (e: string) => T;
1414

15-
export interface EventSourceOptions {
16-
onmessage?: (event: MessageEvent) => void;
15+
export interface EventSourceOptions<T> {
16+
onmessage?: (value: T) => void;
1717
onerror?: (event: MessageEvent) => void;
1818
reconnectTimeout?: number;
1919
}
@@ -88,7 +88,7 @@ export class CallBuilder<
8888
* @param {number} [options.reconnectTimeout] Custom stream connection timeout in ms, default is 15 seconds.
8989
* @returns {function} Close function. Run to close the connection and stop listening for new events.
9090
*/
91-
public stream(options: EventSourceOptions = {}): () => void {
91+
public stream(options: EventSourceOptions<T> = {}): () => void {
9292
this.checkFilter();
9393

9494
this.url.setQuery("X-Client-Name", "js-stellar-sdk");

0 commit comments

Comments
 (0)