@blockworks-foundation/mango-feeds
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -8,3 +8,3 @@ "use strict"; | ||
const fillsFeed = new src_1.FillsFeed('ws://localhost:8080', { | ||
reconnectIntervalMs: RECONNECT_INTERVAL_MS, | ||
reconnectionIntervalMs: RECONNECT_INTERVAL_MS, | ||
reconnectionMaxAttempts: RECONNECT_ATTEMPTS_MAX, | ||
@@ -11,0 +11,0 @@ subscriptions: { |
interface FillsFeedOptions { | ||
subscriptions?: FillsFeedSubscribeParams; | ||
reconnectIntervalMs?: number; | ||
reconnectionIntervalMs?: number; | ||
reconnectionMaxAttempts?: number; | ||
@@ -66,2 +66,3 @@ } | ||
unsubscribe(marketId: string): void; | ||
disconnect(): void; | ||
connected(): boolean; | ||
@@ -68,0 +69,0 @@ onConnect(callback: () => void): void; |
@@ -34,3 +34,3 @@ "use strict"; | ||
this._subscriptions = options?.subscriptions; | ||
this._reconnectionIntervalMs = options?.reconnectIntervalMs ?? 5000; | ||
this._reconnectionIntervalMs = options?.reconnectionIntervalMs ?? 5000; | ||
this._reconnectionAttempts = 0; | ||
@@ -71,3 +71,3 @@ this._reconnectionMaxAttempts = options?.reconnectionMaxAttempts ?? -1; | ||
if (this._onDisconnect) | ||
this._onDisconnect(); | ||
this._onDisconnect(this._reconnectionAttemptsExhausted()); | ||
}); | ||
@@ -114,2 +114,11 @@ this._socket.addEventListener('message', (msg) => { | ||
} | ||
disconnect() { | ||
if (this._connected) { | ||
this._socket.close(); | ||
this._connected = false; | ||
} | ||
else { | ||
console.warn('[FillsFeed] attempt to disconnect when not connected'); | ||
} | ||
} | ||
connected() { | ||
@@ -116,0 +125,0 @@ return this._connected; |
@@ -1,3 +0,2 @@ | ||
import { FillsFeed } from './fills'; | ||
export { FillsFeed }; | ||
export * from './fills'; | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.FillsFeed = void 0; | ||
const fills_1 = require("./fills"); | ||
Object.defineProperty(exports, "FillsFeed", { enumerable: true, get: function () { return fills_1.FillsFeed; } }); | ||
__exportStar(require("./fills"), exports); |
interface FillsFeedOptions { | ||
subscriptions?: FillsFeedSubscribeParams; | ||
reconnectIntervalMs?: number; | ||
reconnectionIntervalMs?: number; | ||
reconnectionMaxAttempts?: number; | ||
@@ -66,2 +66,3 @@ } | ||
unsubscribe(marketId: string): void; | ||
disconnect(): void; | ||
connected(): boolean; | ||
@@ -68,0 +69,0 @@ onConnect(callback: () => void): void; |
@@ -28,3 +28,3 @@ import ws from 'ws'; | ||
this._subscriptions = options?.subscriptions; | ||
this._reconnectionIntervalMs = options?.reconnectIntervalMs ?? 5000; | ||
this._reconnectionIntervalMs = options?.reconnectionIntervalMs ?? 5000; | ||
this._reconnectionAttempts = 0; | ||
@@ -65,3 +65,3 @@ this._reconnectionMaxAttempts = options?.reconnectionMaxAttempts ?? -1; | ||
if (this._onDisconnect) | ||
this._onDisconnect(); | ||
this._onDisconnect(this._reconnectionAttemptsExhausted()); | ||
}); | ||
@@ -108,2 +108,11 @@ this._socket.addEventListener('message', (msg) => { | ||
} | ||
disconnect() { | ||
if (this._connected) { | ||
this._socket.close(); | ||
this._connected = false; | ||
} | ||
else { | ||
console.warn('[FillsFeed] attempt to disconnect when not connected'); | ||
} | ||
} | ||
connected() { | ||
@@ -110,0 +119,0 @@ return this._connected; |
@@ -1,3 +0,2 @@ | ||
import { FillsFeed } from './fills'; | ||
export { FillsFeed }; | ||
export * from './fills'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,2 +0,1 @@ | ||
import { FillsFeed } from './fills'; | ||
export { FillsFeed }; | ||
export * from './fills'; |
interface FillsFeedOptions { | ||
subscriptions?: FillsFeedSubscribeParams; | ||
reconnectIntervalMs?: number; | ||
reconnectionIntervalMs?: number; | ||
reconnectionMaxAttempts?: number; | ||
@@ -66,2 +66,3 @@ } | ||
unsubscribe(marketId: string): void; | ||
disconnect(): void; | ||
connected(): boolean; | ||
@@ -68,0 +69,0 @@ onConnect(callback: () => void): void; |
@@ -1,3 +0,2 @@ | ||
import { FillsFeed } from './fills'; | ||
export { FillsFeed }; | ||
export * from './fills'; | ||
//# sourceMappingURL=index.d.ts.map |
{ | ||
"name": "@blockworks-foundation/mango-feeds", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "Typescript Client for mango-feeds.", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/blockworks-foundation/mango-feeds", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
915636
550