@quantform/core 0.7.0-beta.18 → 0.7.0-beta.20

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,5 +1,7 @@
1
1
  import { Observable } from 'rxjs';
2
- export declare function whenSocket(url: string): [Observable<{
2
+ export declare function whenSocket(url: string, options?: {
3
+ pingInterval?: number;
4
+ }): [Observable<{
3
5
  timestamp: number;
4
6
  payload: unknown;
5
7
  }>, (message: unknown) => void];
@@ -1 +1 @@
1
- {"version":3,"file":"when-socket.d.ts","sourceRoot":"","sources":["../src/when-socket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAMlC,wBAAgB,UAAU,CACxB,GAAG,EAAE,MAAM,GACV,CAAC,UAAU,CAAC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC,CAmDnF"}
1
+ {"version":3,"file":"when-socket.d.ts","sourceRoot":"","sources":["../src/when-socket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAMlC,wBAAgB,UAAU,CACxB,GAAG,EAAE,MAAM,EACX,OAAO,GAAE;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAA2B,GAC1D,CAAC,UAAU,CAAC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC,CAmDnF"}
@@ -5,8 +5,8 @@ const rxjs_1 = require("rxjs");
5
5
  const ws_1 = require("ws");
6
6
  const use_logger_1 = require("./use-logger");
7
7
  const use_timestamp_1 = require("./use-timestamp");
8
- function whenSocket(url) {
9
- const { debug } = (0, use_logger_1.useLogger)('useSocket');
8
+ function whenSocket(url, options = { pingInterval: 5000 }) {
9
+ const { debug } = (0, use_logger_1.useLogger)('whenSocket');
10
10
  const message = new rxjs_1.Observable(stream => {
11
11
  const socket = new ws_1.WebSocket(url);
12
12
  let isAlive = false;
@@ -34,7 +34,7 @@ function whenSocket(url) {
34
34
  socket.terminate();
35
35
  clearInterval(interval);
36
36
  }
37
- }, 5000);
37
+ }, options.pingInterval);
38
38
  socket.on('pong', () => {
39
39
  isAlive = true;
40
40
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quantform/core",
3
- "version": "0.7.0-beta.18",
3
+ "version": "0.7.0-beta.20",
4
4
  "license": "MIT",
5
5
  "author": "Mateusz Majchrzak",
6
6
  "description": "Node.js library for building systematic trading strategies in reactive way.",
@@ -5,9 +5,10 @@ import { useLogger } from './use-logger';
5
5
  import { useTimestamp } from './use-timestamp';
6
6
 
7
7
  export function whenSocket(
8
- url: string
8
+ url: string,
9
+ options: { pingInterval?: number } = { pingInterval: 5000 }
9
10
  ): [Observable<{ timestamp: number; payload: unknown }>, (message: unknown) => void] {
10
- const { debug } = useLogger('useSocket');
11
+ const { debug } = useLogger('whenSocket');
11
12
 
12
13
  const message = new Observable<{ timestamp: number; payload: unknown }>(stream => {
13
14
  const socket = new WebSocket(url);
@@ -38,7 +39,7 @@ export function whenSocket(
38
39
  socket.terminate();
39
40
  clearInterval(interval);
40
41
  }
41
- }, 5000);
42
+ }, options.pingInterval);
42
43
 
43
44
  socket.on('pong', () => {
44
45
  isAlive = true;