From 958bfba66c339d388487e7131402959c89db7553 Mon Sep 17 00:00:00 2001 From: hackademix Date: Tue, 1 Oct 2019 22:46:43 +0200 Subject: SyncMessage support for asynchronous listeners. --- src/lib/SyncMessage.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/lib') diff --git a/src/lib/SyncMessage.js b/src/lib/SyncMessage.js index b9e5006..2f06d3e 100644 --- a/src/lib/SyncMessage.js +++ b/src/lib/SyncMessage.js @@ -82,10 +82,9 @@ console.error(e, "Processing message %o from %o", msg, sender); } } - return { - redirectUrl: `data:application/json,${JSON.stringify(result)}` - }; + return result instanceof Promise ? (async () => ret(await result)) : ret(result); }; + let ret = r => ({redirectUrl: `data:application/json,${JSON.stringify(r)}`}) let listeners = new Set(); browser.runtime.onSyncMessage = { -- cgit v1.2.3