Const
import { PrivateWs } from 'ts-kraken';
let lastHeartbeatTs: number = null;
const maxSecondsWithoutHeartbeat = 10;
PrivateWs.heartbeat$.subscribe(() => {
const now = new Date().getTime();
if (lastHeartbeatTs) {
const diff = (now - lastHeartbeatTs) / 1000;
if (diff > maxSecondsWithoutHeartbeat) {
throw `heartbeat timed out after ${maxSecondsWithoutHeartbeat} seconds`;
}
}
lastHeartbeatTs = now;
});
You can call
.subscribe()
on this RxJS Observable