Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/js/packages/@reactpy/client/src/reactpy-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export type SimpleReactPyClientProps = {
idleDisconnectTimeSeconds?: number;
connectionTimeout?: number;
debugMessages?: boolean;
socketLoopThrottle?: number;
};

/**
Expand Down Expand Up @@ -178,6 +179,7 @@ export class SimpleReactPyClient
private reconnectedCallback: () => void;
private didReconnectingCallback: boolean;
private willReconnect: boolean;
private socketLoopThrottle: number;

constructor(props: SimpleReactPyClientProps) {
super();
Expand All @@ -194,6 +196,7 @@ export class SimpleReactPyClient
this.lastActivityTime = Date.now()
this.reconnectOptions = props.reconnectOptions
this.debugMessages = props.debugMessages || false;
this.socketLoopThrottle = props.socketLoopThrottle || 5;
this.sleeping = false;
this.isReconnecting = false;
this.willReconnect = false;
Expand Down Expand Up @@ -421,7 +424,7 @@ export class SimpleReactPyClient
onMessage: async ({ data }) => { this.lastActivityTime = Date.now(); this.handleIncoming(JSON.parse(data)) },
...this.reconnectOptions,
});
this.socketLoopIntervalId = window.setInterval(() => { this.socketLoop() }, 30);
this.socketLoopIntervalId = window.setInterval(() => { this.socketLoop() }, this.socketLoopThrottle);
this.idleCheckIntervalId = window.setInterval(() => { this.idleTimeoutCheck() }, 10000);

}, interval)
Expand Down