Skip to content

Commit

Permalink
restartWebflow: Added an awaitable promise as the return value
Browse files Browse the repository at this point in the history
  • Loading branch information
alexiglesias93 committed Sep 27, 2021
1 parent b1f65e9 commit a8f242b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
7 changes: 5 additions & 2 deletions webflow/restartWebflow.ts
Original file line number Diff line number Diff line change
@@ -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<unknown> => {
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)));
};

0 comments on commit a8f242b

Please sign in to comment.