@ombori/ga-messaging
Advanced tools
Comparing version 2.63.3 to 2.63.4
@@ -6,2 +6,13 @@ # Change Log | ||
## [2.63.4](https://github.com/ombori/gridapp/compare/v2.63.3...v2.63.4) (2021-06-07) | ||
### Bug Fixes | ||
* useHeartbeat ([b38a1fd](https://github.com/ombori/gridapp/commit/b38a1fdc98755ece7297512d6b5d57dc6958242a)) | ||
## [2.63.3](https://github.com/ombori/gridapp/compare/v2.63.2...v2.63.3) (2021-06-07) | ||
@@ -8,0 +19,0 @@ |
@@ -11,2 +11,3 @@ export declare type Message = { | ||
export declare const useStatus: () => boolean; | ||
export declare const useHeartbeat: () => void; | ||
declare const _default: { | ||
@@ -19,4 +20,5 @@ usePublish: () => (message: string | Message, payload: { | ||
useStatus: () => boolean; | ||
useHeartbeat: () => void; | ||
}; | ||
export default _default; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -12,3 +12,3 @@ var __assign = (this && this.__assign) || function () { | ||
}; | ||
import React from 'react'; | ||
import { useState, useEffect } from 'react'; | ||
var RECONNECT_TIMEOUT = 10000; | ||
@@ -35,15 +35,10 @@ var _a = process.env, _b = _a.REACT_APP_MESSAGING_URL, REACT_APP_MESSAGING_URL = _b === void 0 ? '' : _b, NODE_ENV = _a.NODE_ENV; | ||
}; | ||
setInterval(function () { | ||
if (socket && socket.readyState == socket.OPEN) { | ||
send('App.Heartbeat', {}); | ||
} | ||
}, 30000); | ||
var send = function (message, payload) { | ||
try { | ||
if (payload) { | ||
console.log('publishing', message, payload); | ||
// console.log('publishing', message, payload); | ||
socket.send(JSON.stringify(__assign({ type: message }, payload))); | ||
} | ||
else { | ||
console.log('publishing', message); | ||
// console.log('publishing', message); | ||
socket.send(JSON.stringify(message)); | ||
@@ -86,3 +81,3 @@ } | ||
if (deps === void 0) { deps = emptyDeps; } | ||
React.useEffect(function () { | ||
useEffect(function () { | ||
handlers.push([type, callback]); | ||
@@ -105,4 +100,4 @@ return function () { | ||
export var useStatus = function () { | ||
var _a = React.useState(false), conn = _a[0], setConn = _a[1]; | ||
React.useEffect(function () { | ||
var _a = useState(false), conn = _a[0], setConn = _a[1]; | ||
useEffect(function () { | ||
var int = setInterval(function () { return setConn(socket && socket.readyState == socket.OPEN); }, 1000); | ||
@@ -113,2 +108,10 @@ return function () { return clearInterval(int); }; | ||
}; | ||
export default { usePublish: usePublish, useSubscribe: useSubscribe, setSpaceId: setSpaceId, useStatus: useStatus }; | ||
export var useHeartbeat = function () { | ||
useEffect(function () { | ||
var i = setInterval(function () { | ||
send('App.Heartbeat', { manual: true }); | ||
}, 5000); | ||
return function () { return clearInterval(i); }; | ||
}, []); | ||
}; | ||
export default { usePublish: usePublish, useSubscribe: useSubscribe, setSpaceId: setSpaceId, useStatus: useStatus, useHeartbeat: useHeartbeat }; |
{ | ||
"name": "@ombori/ga-messaging", | ||
"version": "2.63.3", | ||
"version": "2.63.4", | ||
"main": "dist/index.js", | ||
@@ -16,3 +16,3 @@ "license": "UNLICENSED", | ||
}, | ||
"gitHead": "063a45892482026be6b5a3b2cf1c1fa7a7a845c4" | ||
"gitHead": "95b6d95773931af1e2dfbdaa87d626072e9deefe" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12646
271