@waves.exchange/config-ws
Advanced tools
Comparing version
@@ -6,4 +6,4 @@ import { BehaviorSubject } from '@waves.exchange/reactive'; | ||
errorsSubject: BehaviorSubject<SocketErrorEvent>; | ||
private readonly _topicks; | ||
private readonly _url; | ||
private _topics; | ||
private _configWebSocket; | ||
@@ -10,0 +10,0 @@ private _connectConfigTimeout; |
@@ -17,3 +17,3 @@ "use strict"; | ||
this.errorsSubject = new reactive_1.BehaviorSubject({}); | ||
this._topicks = Object.create(null); | ||
this._topics = Object.create(null); | ||
this._isOpened = false; | ||
@@ -37,3 +37,3 @@ this._initialValueTimers = Object.create(null); | ||
const topic = `topic://${filePath}`; | ||
if (!this._topicks[filePath]) { | ||
if (!this._topics[filePath]) { | ||
const ws = (this._configWebSocket || | ||
@@ -50,3 +50,3 @@ this.ensureConfigWebSocket()); | ||
}, this._timeout.initialValue); | ||
this._topicks[filePath] = ws.multiplex(() => ({ type: 'subscribe', topic }), () => ({ type: 'unsubscribe', topic }), (message) => message.topic === topic && (message.type === 'update' || message.type === 'subscribed')).subscribe(data => { | ||
this._topics[filePath] = ws.multiplex(() => ({ type: 'subscribe', topic }), () => ({ type: 'unsubscribe', topic }), (message) => message.topic === topic && (message.type === 'update' || message.type === 'subscribed')).subscribe(data => { | ||
clearTimeout(this._initialValueTimers[topic]); | ||
@@ -66,5 +66,5 @@ const oldConfigs = this.configSubject.getValue().configs; | ||
const values = this.configSubject.getValue(); | ||
if (this._topicks[filePath]) { | ||
this._topicks[filePath].unsubscribe(); | ||
delete this._topicks[filePath]; | ||
if (this._topics[filePath]) { | ||
this._topics[filePath].unsubscribe(); | ||
delete this._topics[filePath]; | ||
} | ||
@@ -102,2 +102,3 @@ if (!ensureConfig && values != null && values.configs != null) { | ||
this._lastMessage = 0; | ||
this._topics = Object.create(null); | ||
Object.values(this._initialValueTimers).forEach(timer => { | ||
@@ -161,2 +162,3 @@ clearTimeout(timer); | ||
if (this._lastMessage + 1 !== message.message_number) { | ||
this._topics = Object.create(null); | ||
this.errorsSubject.next({ | ||
@@ -163,0 +165,0 @@ code: 4, |
{ | ||
"name": "@waves.exchange/config-ws", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "typings": "dist/index.d.ts", |
@@ -20,4 +20,4 @@ import { WebSocketSubject, webSocket, BehaviorSubject } from '@waves.exchange/reactive'; | ||
private readonly _topicks = Object.create(null); | ||
private readonly _url: string; | ||
private _topics = Object.create(null); | ||
private _configWebSocket: WebSocketSubject<unknown> | undefined; | ||
@@ -49,3 +49,3 @@ private _connectConfigTimeout: number | undefined; | ||
const topic = `topic://${filePath}`; | ||
if (!this._topicks[filePath]) { | ||
if (!this._topics[filePath]) { | ||
const ws = ( | ||
@@ -66,3 +66,3 @@ this._configWebSocket || | ||
this._topicks[filePath] = ws.multiplex( | ||
this._topics[filePath] = ws.multiplex( | ||
() => ({ type: 'subscribe', topic }), | ||
@@ -92,5 +92,5 @@ () => ({ type: 'unsubscribe', topic }), | ||
if (this._topicks[filePath]) { | ||
this._topicks[filePath].unsubscribe(); | ||
delete this._topicks[filePath]; | ||
if (this._topics[filePath]) { | ||
this._topics[filePath].unsubscribe(); | ||
delete this._topics[filePath]; | ||
} | ||
@@ -136,2 +136,3 @@ | ||
this._lastMessage = 0; | ||
this._topics = Object.create(null); | ||
Object.values(this._initialValueTimers).forEach(timer => { | ||
@@ -198,2 +199,3 @@ clearTimeout(timer); | ||
if (this._lastMessage + 1 !== message.message_number) { | ||
this._topics = Object.create(null); | ||
this.errorsSubject.next({ | ||
@@ -200,0 +202,0 @@ code: 4, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
26754
1.03%498
0.81%