diff --git a/packages/ui-did-keyring/src/KiltDid.ts b/packages/ui-did-keyring/src/KiltDid.ts index 0327162..94ea273 100644 --- a/packages/ui-did-keyring/src/KiltDid.ts +++ b/packages/ui-did-keyring/src/KiltDid.ts @@ -34,9 +34,7 @@ export class KiltDid extends KiltDidSuper { jsons.forEach((json) => this.keyring.addFromJson(json)); dids.forEach((did) => super.addDid(did)); - - resolve(); - }); + }, resolve); }); } diff --git a/packages/ui-did-keyring/src/ZkDid.ts b/packages/ui-did-keyring/src/ZkDid.ts index 56f7943..576895d 100644 --- a/packages/ui-did-keyring/src/ZkDid.ts +++ b/packages/ui-did-keyring/src/ZkDid.ts @@ -38,9 +38,7 @@ export class ZkDid extends ZkDidSuper { this.dids.set(did.id, did); }); - - resolve(); - }); + }, resolve); }); } diff --git a/packages/ui-store/src/BaseStore.ts b/packages/ui-store/src/BaseStore.ts index b75e7d8..79ff04b 100644 --- a/packages/ui-store/src/BaseStore.ts +++ b/packages/ui-store/src/BaseStore.ts @@ -4,8 +4,8 @@ import { Events } from './event/Event'; export abstract class BaseStore extends Events { - abstract all(fn: (key: string, value: unknown) => void): void; - abstract get(key: string, fn: (value: unknown) => void): void; - abstract set(key: string, value: unknown, fn?: () => void): void; - abstract remove(key: string, fn?: () => void): void; + public abstract all(fn: (key: string, value: unknown) => void, done?: () => void): void; + public abstract get(key: string, fn: (value: unknown) => void): void; + public abstract set(key: string, value: unknown, fn?: () => void): void; + public abstract remove(key: string, fn?: () => void): void; } diff --git a/packages/ui-store/src/BrowserSession.ts b/packages/ui-store/src/BrowserSession.ts index 4c546ac..5a86741 100644 --- a/packages/ui-store/src/BrowserSession.ts +++ b/packages/ui-store/src/BrowserSession.ts @@ -12,10 +12,11 @@ export class BrowserSession extends BaseStore { this.#session = new SessionStorage(); } - public all(fn: (key: string, value: unknown) => void): void { + public all(fn: (key: string, value: unknown) => void, done?: () => void): void { this.#session.each((key: string, value: unknown): void => { fn(key, value); }); + done?.(); } public get(key: string, fn: (value: unknown) => void): void { diff --git a/packages/ui-store/src/BrowserStore.ts b/packages/ui-store/src/BrowserStore.ts index d52a5c2..ebad900 100644 --- a/packages/ui-store/src/BrowserStore.ts +++ b/packages/ui-store/src/BrowserStore.ts @@ -16,10 +16,11 @@ export class BrowserStore extends BaseStore { }); } - public all(fn: (key: string, value: unknown) => void): void { + public all(fn: (key: string, value: unknown) => void, done?: () => void): void { this.#store.each((key: string, value: unknown): void => { fn(key, value); }); + done?.(); } public get(key: string, fn: (value: unknown) => void): void { diff --git a/packages/ui-store/src/ExtensionSession.ts b/packages/ui-store/src/ExtensionSession.ts index 6a92745..0ae9a91 100644 --- a/packages/ui-store/src/ExtensionSession.ts +++ b/packages/ui-store/src/ExtensionSession.ts @@ -18,11 +18,13 @@ export class ExtensionSession extends BaseStore { }); } - public all(fn: (key: string, value: string) => void) { + public all(fn: (key: string, value: string) => void, done?: () => void) { session.get(null, (items) => { for (const key in items) { fn(key, items[key]); } + + done?.(); }); } diff --git a/packages/ui-store/src/ExtensionStore.ts b/packages/ui-store/src/ExtensionStore.ts index fbbc949..dc39c23 100644 --- a/packages/ui-store/src/ExtensionStore.ts +++ b/packages/ui-store/src/ExtensionStore.ts @@ -18,11 +18,13 @@ export class ExtensionStore extends BaseStore { }); } - public all(fn: (key: string, value: string) => void) { + public all(fn: (key: string, value: string) => void, done?: () => void) { storage.get(null, (items) => { for (const key in items) { fn(key, items[key]); } + + done?.(); }); }