Skip to content

Commit

Permalink
grid.Container: addResizeObserver() => lazy load the addon, in case i…
Browse files Browse the repository at this point in the history
…t is not inside mainThreadAddons #6299
  • Loading branch information
tobiu committed Jan 26, 2025
1 parent 315c3b7 commit 47620b4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/Main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ class Main extends core.Base {
}

this.registerAddon(module.default);
await this.timeout(20); // Wait until remotes are registered

return true
}
Expand Down
22 changes: 11 additions & 11 deletions src/grid/Container.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -236,20 +236,20 @@ class GridContainer extends BaseContainer {
async addResizeObserver(mounted) {
let me = this,
ResizeObserver = Neo.main?.addon?.ResizeObserver,
resizeParams = {id: me.id, windowId: me.windowId};
{windowId} = me,
resizeParams = {id: me.id, windowId};

// Check if the remotes api is ready for slow network connections & dist/prod
if (!ResizeObserver) {
await me.timeout(100);
await me.addResizeObserver(mounted)
await Neo.Main.importAddon({name: 'ResizeObserver', windowId});
ResizeObserver = Neo.main.addon.ResizeObserver
}

if (mounted) {
ResizeObserver.register(resizeParams);
await me.passSizeToView()
} else {
if (mounted) {
ResizeObserver.register(resizeParams);
await me.passSizeToView()
} else {
me.initialResizeEvent = true;
ResizeObserver.unregister(resizeParams)
}
me.initialResizeEvent = true;
ResizeObserver.unregister(resizeParams)
}
}

Expand Down

0 comments on commit 47620b4

Please sign in to comment.