From a8f242b9f50aed6c1399980ef921406ddb57c1af Mon Sep 17 00:00:00 2001 From: Alex Iglesias Date: Mon, 27 Sep 2021 12:10:13 +0200 Subject: [PATCH] restartWebflow: Added an awaitable promise as the return value --- package.json | 2 +- webflow/restartWebflow.ts | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 2431cbb..9e50a2c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@finsweet/ts-utils", - "version": "0.13.3", + "version": "0.13.4", "description": "Typescript utils for custom Webflow projects.", "main": "index.ts", "module": "index.ts", diff --git a/webflow/restartWebflow.ts b/webflow/restartWebflow.ts index a49f174..f13a9c3 100644 --- a/webflow/restartWebflow.ts +++ b/webflow/restartWebflow.ts @@ -1,11 +1,14 @@ /** - * Restart Webflow JS library + * Restarts the Webflow JS library. + * @returns An awaitable promise that is fulfilled when the library has been correctly reinitialized. */ -export const restartWebflow = (): void => { +export const restartWebflow = async (): Promise => { const { Webflow } = window; if (!Webflow || !('destroy' in Webflow) || !('ready' in Webflow) || !('require' in Webflow)) return; Webflow.destroy(); Webflow.ready(); Webflow.require('ix2')?.init(); + + return new Promise((resolve) => Webflow.push(() => resolve(undefined))); };