From 53c918cc785ee3769103acc3e15aa9275c9383d9 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Sun, 12 Nov 2017 12:09:14 -0500 Subject: Clear cache on unsubscribe --- src/order_watcher/order_state_watcher.ts | 2 ++ src/stores/balance_proxy_allowance_lazy_store.ts | 4 ++++ src/stores/order_filled_cancelled_lazy_store.ts | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/src/order_watcher/order_state_watcher.ts b/src/order_watcher/order_state_watcher.ts index c4914fc64..a19d6be9c 100644 --- a/src/order_watcher/order_state_watcher.ts +++ b/src/order_watcher/order_state_watcher.ts @@ -148,6 +148,8 @@ export class OrderStateWatcher { throw new Error(ZeroExError.SubscriptionNotFound); } this._blockStore.stop(); + this._balanceAndProxyAllowanceLazyStore.deleteAll(); + this._orderFilledCancelledLazyStore.deleteAll(); delete this._callbackIfExistsAsync; this._eventWatcher.unsubscribe(); } diff --git a/src/stores/balance_proxy_allowance_lazy_store.ts b/src/stores/balance_proxy_allowance_lazy_store.ts index a2b8fcf67..ac21c0818 100644 --- a/src/stores/balance_proxy_allowance_lazy_store.ts +++ b/src/stores/balance_proxy_allowance_lazy_store.ts @@ -75,4 +75,8 @@ export class BalanceAndProxyAllowanceLazyStore { delete this.proxyAllowance[tokenAddress][userAddress]; } } + public deleteAll(): void { + this.balance = {}; + this.proxyAllowance = {}; + } } diff --git a/src/stores/order_filled_cancelled_lazy_store.ts b/src/stores/order_filled_cancelled_lazy_store.ts index 978de0b18..5b0dab35c 100644 --- a/src/stores/order_filled_cancelled_lazy_store.ts +++ b/src/stores/order_filled_cancelled_lazy_store.ts @@ -60,4 +60,8 @@ export class OrderFilledCancelledLazyStore { public deleteCancelledTakerAmount(orderHash: string): void { delete this.cancelledTakerAmount[orderHash]; } + public deleteAll(): void { + this.filledTakerAmount = {}; + this.cancelledTakerAmount = {}; + } } -- cgit v1.2.3