Skip to content

Commit

Permalink
use Nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
117 authored Jun 9, 2024
1 parent bfdd6da commit 8d7e4e0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions factory/createStream.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// NOT CLEANED UP; TYPES MISSING FOR CALLBACKS

import { Nullable } from "../api/trade.ts";

const baseURLs = {
data: "wss://stream.data.alpaca.markets",
data_sandbox: "wss://stream.data.sandbox.alpaca.markets",
Expand Down Expand Up @@ -53,7 +55,7 @@ export const createStream = (options: CreateStreamOptions): void => {
url = `${baseURLs[type]}/stream`;
}

let socket: WebSocket | null = null;
let socket: Nullable<WebSocket> = null;
let retries = 0;

// Handle incoming messages
Expand All @@ -75,15 +77,15 @@ export const createStream = (options: CreateStreamOptions): void => {

socket.onopen = () => {
console.debug(
"WebSocket connection established. Sending authentication message."
"WebSocket connection established. Sending authentication message.",
);

socket?.send(
JSON.stringify({
action: "auth",
key: key,
secret: secret,
})
}),
);
};

Expand Down

0 comments on commit 8d7e4e0

Please sign in to comment.