quidproquo-web-react 0.0.239 → 0.0.240

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- export declare function useRunEvery<T>(func: () => T, interval: number): T;
1
+ export declare function useRunEvery<T>(func: () => T, intervalSeconds: number): T;
@@ -2,21 +2,21 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useRunEvery = void 0;
4
4
  const react_1 = require("react");
5
- function useRunEvery(func, interval) {
5
+ function useRunEvery(func, intervalSeconds) {
6
6
  const [value, setValue] = (0, react_1.useState)(func);
7
7
  const intervalRef = (0, react_1.useRef)(null);
8
8
  (0, react_1.useEffect)(() => {
9
9
  intervalRef.current = window.setInterval(() => {
10
10
  const newValue = func();
11
11
  setValue(newValue);
12
- }, interval * 1000);
12
+ }, intervalSeconds * 1000);
13
13
  return () => {
14
14
  if (intervalRef.current !== null) {
15
15
  window.clearInterval(intervalRef.current);
16
16
  intervalRef.current = null;
17
17
  }
18
18
  };
19
- }, [interval]);
19
+ }, [intervalSeconds]);
20
20
  return value;
21
21
  }
22
22
  exports.useRunEvery = useRunEvery;
@@ -15,7 +15,7 @@ const useWebsocketAuthSync = (accessToken) => {
15
15
  }
16
16
  if (accessToken) {
17
17
  const authMessage = {
18
- type: quidproquo_webserver_1.WebsocketClientMessageEventType.Authenticate,
18
+ type: quidproquo_webserver_1.WebSocketQueueClientMessageEventType.Authenticate,
19
19
  payload: {
20
20
  accessToken: accessToken,
21
21
  },
@@ -24,7 +24,7 @@ const useWebsocketAuthSync = (accessToken) => {
24
24
  }
25
25
  else {
26
26
  const authMessage = {
27
- type: quidproquo_webserver_1.WebsocketClientMessageEventType.Unauthenticate,
27
+ type: quidproquo_webserver_1.WebSocketQueueClientMessageEventType.Unauthenticate,
28
28
  };
29
29
  sendMessage(authMessage);
30
30
  }
@@ -2,20 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useWebsocketPingPong = void 0;
4
4
  const quidproquo_webserver_1 = require("quidproquo-webserver");
5
- const react_1 = require("react");
6
- const hooks_1 = require("../../hooks");
5
+ const hooks_1 = require("../../../hooks");
6
+ const hooks_2 = require("../../hooks");
7
7
  const useWebsocketPingPong = () => {
8
- const sendMessage = (0, hooks_1.useWebsocketSendEvent)();
9
- (0, react_1.useEffect)(() => {
10
- const intervalId = setInterval(() => {
11
- const pingEvent = {
12
- type: quidproquo_webserver_1.WebsocketClientMessageEventType.Ping,
13
- };
14
- sendMessage(pingEvent);
15
- }, 8 * 60 * 1000);
16
- return () => {
17
- clearInterval(intervalId);
8
+ const sendMessage = (0, hooks_2.useWebsocketSendEvent)();
9
+ (0, hooks_1.useRunEvery)(() => {
10
+ const pingEvent = {
11
+ type: quidproquo_webserver_1.WebSocketQueueClientMessageEventType.Ping,
18
12
  };
19
- }, [sendMessage]);
13
+ sendMessage(pingEvent);
14
+ }, 8 * 60);
20
15
  };
21
16
  exports.useWebsocketPingPong = useWebsocketPingPong;
@@ -1 +1 @@
1
- export declare function useRunEvery<T>(func: () => T, interval: number): T;
1
+ export declare function useRunEvery<T>(func: () => T, intervalSeconds: number): T;
@@ -1,18 +1,18 @@
1
1
  import { useEffect, useRef, useState } from 'react';
2
- export function useRunEvery(func, interval) {
2
+ export function useRunEvery(func, intervalSeconds) {
3
3
  const [value, setValue] = useState(func);
4
4
  const intervalRef = useRef(null);
5
5
  useEffect(() => {
6
6
  intervalRef.current = window.setInterval(() => {
7
7
  const newValue = func();
8
8
  setValue(newValue);
9
- }, interval * 1000);
9
+ }, intervalSeconds * 1000);
10
10
  return () => {
11
11
  if (intervalRef.current !== null) {
12
12
  window.clearInterval(intervalRef.current);
13
13
  intervalRef.current = null;
14
14
  }
15
15
  };
16
- }, [interval]);
16
+ }, [intervalSeconds]);
17
17
  return value;
18
18
  }
@@ -1,5 +1,5 @@
1
1
  import { WebsocketServiceEvent } from 'quidproquo-web';
2
- import { WebsocketClientMessageEventType, } from 'quidproquo-webserver';
2
+ import { WebSocketQueueClientMessageEventType, } from 'quidproquo-webserver';
3
3
  import { useEffect } from 'react';
4
4
  import { useFastCallback } from '../../../hooks';
5
5
  import { useSubscribeToWebsocket, useWebsocketApi, useWebsocketSendEvent } from '../../hooks';
@@ -12,7 +12,7 @@ export const useWebsocketAuthSync = (accessToken) => {
12
12
  }
13
13
  if (accessToken) {
14
14
  const authMessage = {
15
- type: WebsocketClientMessageEventType.Authenticate,
15
+ type: WebSocketQueueClientMessageEventType.Authenticate,
16
16
  payload: {
17
17
  accessToken: accessToken,
18
18
  },
@@ -21,7 +21,7 @@ export const useWebsocketAuthSync = (accessToken) => {
21
21
  }
22
22
  else {
23
23
  const authMessage = {
24
- type: WebsocketClientMessageEventType.Unauthenticate,
24
+ type: WebSocketQueueClientMessageEventType.Unauthenticate,
25
25
  };
26
26
  sendMessage(authMessage);
27
27
  }
@@ -1,17 +1,12 @@
1
- import { WebsocketClientMessageEventType } from 'quidproquo-webserver';
2
- import { useEffect } from 'react';
1
+ import { WebSocketQueueClientMessageEventType } from 'quidproquo-webserver';
2
+ import { useRunEvery } from '../../../hooks';
3
3
  import { useWebsocketSendEvent } from '../../hooks';
4
4
  export const useWebsocketPingPong = () => {
5
5
  const sendMessage = useWebsocketSendEvent();
6
- useEffect(() => {
7
- const intervalId = setInterval(() => {
8
- const pingEvent = {
9
- type: WebsocketClientMessageEventType.Ping,
10
- };
11
- sendMessage(pingEvent);
12
- }, 8 * 60 * 1000);
13
- return () => {
14
- clearInterval(intervalId);
6
+ useRunEvery(() => {
7
+ const pingEvent = {
8
+ type: WebSocketQueueClientMessageEventType.Ping,
15
9
  };
16
- }, [sendMessage]);
10
+ sendMessage(pingEvent);
11
+ }, 8 * 60);
17
12
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quidproquo-web-react",
3
- "version": "0.0.239",
3
+ "version": "0.0.240",
4
4
  "description": "",
5
5
  "main": "./lib/commonjs/index.js",
6
6
  "module": "./lib/esm/index.js",
@@ -32,10 +32,10 @@
32
32
  },
33
33
  "homepage": "https://github.com/joe-coady/quidproquo#readme",
34
34
  "devDependencies": {
35
- "quidproquo-core": "0.0.239",
36
- "quidproquo-tsconfig": "0.0.239",
37
- "quidproquo-webserver": "0.0.239",
38
- "quidproquo-web": "0.0.239",
35
+ "quidproquo-core": "0.0.240",
36
+ "quidproquo-tsconfig": "0.0.240",
37
+ "quidproquo-webserver": "0.0.240",
38
+ "quidproquo-web": "0.0.240",
39
39
  "typescript": "^4.9.3"
40
40
  },
41
41
  "peerDependencies": {