aboutsummaryrefslogtreecommitdiff
path: root/src/util/asyncMemo.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2019-12-15 16:59:00 +0100
committerFlorian Dold <florian.dold@gmail.com>2019-12-15 16:59:00 +0100
commit4966376839365536923cd6cfbb86d15071432e1a (patch)
tree6658b4a84df5ba6a0189e6d79e37fb0cc7fb597a /src/util/asyncMemo.ts
parentf4043a0f8114b1b8612e01a5cdf65b8d6ffc6f00 (diff)
downloadwallet-core-4966376839365536923cd6cfbb86d15071432e1a.tar.xz
group refresh sessions into groups for nicer history
Diffstat (limited to 'src/util/asyncMemo.ts')
-rw-r--r--src/util/asyncMemo.ts13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/util/asyncMemo.ts b/src/util/asyncMemo.ts
index 193ce6df6..17204a88e 100644
--- a/src/util/asyncMemo.ts
+++ b/src/util/asyncMemo.ts
@@ -39,15 +39,14 @@ export class AsyncOpMemoMap<T> {
const n = this.n++;
// Wrap the operation in case it immediately throws
const p = Promise.resolve().then(() => pg());
- p.finally(() => {
- this.cleanUp(key, n);
- });
this.memoMap[key] = {
- p,
- n,
- t: new Date().getTime(),
+ p,
+ n,
+ t: new Date().getTime(),
};
- return p;
+ return p.finally(() => {
+ this.cleanUp(key, n);
+ });
}
clear() {
this.memoMap = {};