From 71fdfd1fa9d9bf8f00cac7e9d97127a2f6206de7 Mon Sep 17 00:00:00 2001 From: Michael Rawlings Date: Fri, 10 Apr 2020 07:53:39 -0700 Subject: [PATCH] fix: return the result of fireEvent in our async wrapper --- src/shared.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/shared.ts b/src/shared.ts index 4bf3b62..039fb7c 100644 --- a/src/shared.ts +++ b/src/shared.ts @@ -36,30 +36,32 @@ export type InternalEventNames = typeof INTERNAL_EVENTS[number]; export type FireFunction = ( ...params: Parameters -) => Promise; +) => Promise>; export type FireObject = { [K in EventType]: ( ...params: Parameters - ) => Promise; + ) => Promise>; }; export const fireEvent = (async (...params) => { failIfNoWindow(); - originalFireEvent(...params); + const result = originalFireEvent(...params); await wait(); + return result; }) as FireFunction & FireObject; Object.keys(originalFireEvent).forEach((eventName: EventType) => { const fire = originalFireEvent[eventName]; fireEvent[eventName] = async (...params) => { failIfNoWindow(); - fire(...params); + const result = fire(...params); // TODO: this waits for a possible update using setTimeout(0) which should // be sufficient, but ideally we would hook into the Marko lifecycle to // determine when all pending updates are complete. await wait(); + return result; }; });