Skip to content

Commit

Permalink
feat(plugins-runtime): add close callback to load api
Browse files Browse the repository at this point in the history
  • Loading branch information
Alotor committed Oct 10, 2024
1 parent b4d0463 commit aeddab7
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions libs/plugins-runtime/src/lib/load-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -50,6 +53,7 @@ export const loadPlugin = async function (manifest: Manifest) {
manifest,
() => {
plugins = plugins.filter((api) => api !== plugin);
closeCallback && closeCallback();
}
);

Expand All @@ -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) {
Expand Down

0 comments on commit aeddab7

Please sign in to comment.