Skip to content

Commit

Permalink
fix: reload flow after hmr reload in dev mode (#19323) (#19348)
Browse files Browse the repository at this point in the history
Reset and reload flow when a
template hrm reload happens.

Fixes #19291

Co-authored-by: caalador <mikael.grankvist@vaadin.com>
  • Loading branch information
vaadin-bot and caalador committed May 10, 2024
1 parent 514fe0b commit 2ba5d4f
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion flow-client/src/main/frontend/FlowBootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,36 @@ Please submit an issue to https://github.com/vaadin/flow-components/issues/new/c
throw new Error('Application ' + appId + ' is already being initialized');
}
if (isInitializedInDom(appId)) {
throw new Error('Application ' + appId + ' already initialized');
if (appInitResponse.appConfig.productionMode) {
throw new Error('Application ' + appId + ' already initialized');
}

// Remove old contents for Flow
var appDiv = document.getElementById(appId);
for (var i = 0; i < appDiv.childElementCount; i++) {
appDiv.childNodes[i].remove();
}

// For devMode reset app config and restart widgetset as client
// is up and running after hrm update.
const getConfig = function (name) {
return config[name];
};

/* Export public data */
const app = {
getConfig: getConfig
};
apps[appId] = app;

if (widgetsets['client'].callback) {
log('Starting from bootstrap', appId);
widgetsets['client'].callback(appId);
} else {
log('Setting pending startup', appId);
widgetsets['client'].pendingApps.push(appId);
}
return apps[appId];
}
}

Expand Down

0 comments on commit 2ba5d4f

Please sign in to comment.