From aeddab79179c4bf151ffe82d39d48c7c9f55fe60 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Thu, 10 Oct 2024 13:10:07 +0200 Subject: [PATCH] feat(plugins-runtime): add close callback to load api --- libs/plugins-runtime/src/lib/load-plugin.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/libs/plugins-runtime/src/lib/load-plugin.ts b/libs/plugins-runtime/src/lib/load-plugin.ts index bf76842..e0b6281 100644 --- a/libs/plugins-runtime/src/lib/load-plugin.ts +++ b/libs/plugins-runtime/src/lib/load-plugin.ts @@ -35,7 +35,10 @@ window.addEventListener('message', (event) => { } }); -export const loadPlugin = async function (manifest: Manifest) { +export const loadPlugin = async function ( + manifest: Manifest, + closeCallback?: () => void +) { try { const context = contextBuilder && contextBuilder(manifest.pluginId); @@ -50,6 +53,7 @@ export const loadPlugin = async function (manifest: Manifest) { manifest, () => { plugins = plugins.filter((api) => api !== plugin); + closeCallback && closeCallback(); } ); @@ -60,8 +64,11 @@ export const loadPlugin = async function (manifest: Manifest) { } }; -export const ɵloadPlugin = async function (manifest: Manifest) { - loadPlugin(manifest); +export const ɵloadPlugin = async function ( + manifest: Manifest, + closeCallback?: () => void +) { + loadPlugin(manifest, closeCallback); }; export const ɵloadPluginByUrl = async function (manifestUrl: string) {