Hello everyone,
this is the first breaking change in a long time, but I am afraid it needs to happen.
So far, our app.mjs files looked like:
import MainContainer from './view/MainContainer.mjs';
Neo.onStart = () => Neo.app({
appPath : 'apps/shareddialog/',
mainView: MainContainer,
name : 'SharedDialog'
});
While this is perfectly fine for single page apps, it is actually not for the SharedWorkers context.
If we load our first app, we define Neo.onStart() and trigger it. Now if we load a different app, we will override Neo.onStart() and trigger the new method. Works fine as well. The problem starts, when we want to reload our first app window:
Browsers are "smart", so they will cache the module. In this case, Neo.onStart() will not get overridden again and we will trigger the last version of it.
Results are:
(look close at the URLs)
To fix this, I will adjust the starting points to the following:
import MainContainer from './view/MainContainer.mjs';
const onStart = () => Neo.app({
appPath : 'apps/shareddialog/',
mainView: MainContainer,
name : 'SharedDialog'
});
export {onStart as onStart};
We will export the onStart() method and no longer use Neo.onStart() at all. This change ensures, that we will always get the correct method.
While this is easy to fix for the dev mode, it is a bit painful for the webpack based dist versions.
I found a way that works, although it is not exactly beautiful:
onLoadApplication(data) {
let me = this,
path;
if (data) {console.log(data);
me.data = data;
Neo.config.resourcesPath = data.resourcesPath;
}
if (!Neo.config.isExperimental) {
path = data.path.replace('.js', '.mjs');
path = path.substring(0) === '.' ? path : '.' + path;
__webpack_require__.c[path].exports.onStart();
//Neo.onStart();
if (Neo.config.hash) {
setTimeout(() => HashHistory.push(Neo.config.hash), 5);
}
} else {
import(
/* webpackIgnore: true */
`../../${me.data.path}`).then(module => {
// Neo.onStart();
module.onStart();
if (Neo.config.hash) {
// short delay to ensure Component Controllers are ready
setTimeout(() => HashHistory.push(Neo.config.hash), 5);
}
}
);
}
}
I will adjust all starting points now and afterwards the build scripts (including the npx neo-app repo).
Best regards,
Tobi
Hello everyone,
this is the first breaking change in a long time, but I am afraid it needs to happen.
So far, our app.mjs files looked like:
import MainContainer from './view/MainContainer.mjs'; Neo.onStart = () => Neo.app({ appPath : 'apps/shareddialog/', mainView: MainContainer, name : 'SharedDialog' });While this is perfectly fine for single page apps, it is actually not for the SharedWorkers context.
If we load our first app, we define Neo.onStart() and trigger it. Now if we load a different app, we will override Neo.onStart() and trigger the new method. Works fine as well. The problem starts, when we want to reload our first app window:
Browsers are "smart", so they will cache the module. In this case, Neo.onStart() will not get overridden again and we will trigger the last version of it.
Results are:
(look close at the URLs)
To fix this, I will adjust the starting points to the following:
import MainContainer from './view/MainContainer.mjs'; const onStart = () => Neo.app({ appPath : 'apps/shareddialog/', mainView: MainContainer, name : 'SharedDialog' }); export {onStart as onStart};We will export the onStart() method and no longer use Neo.onStart() at all. This change ensures, that we will always get the correct method.
While this is easy to fix for the dev mode, it is a bit painful for the webpack based dist versions.
I found a way that works, although it is not exactly beautiful:
onLoadApplication(data) { let me = this, path; if (data) {console.log(data); me.data = data; Neo.config.resourcesPath = data.resourcesPath; } if (!Neo.config.isExperimental) { path = data.path.replace('.js', '.mjs'); path = path.substring(0) === '.' ? path : '.' + path; __webpack_require__.c[path].exports.onStart(); //Neo.onStart(); if (Neo.config.hash) { setTimeout(() => HashHistory.push(Neo.config.hash), 5); } } else { import( /* webpackIgnore: true */ `../../${me.data.path}`).then(module => { // Neo.onStart(); module.onStart(); if (Neo.config.hash) { // short delay to ensure Component Controllers are ready setTimeout(() => HashHistory.push(Neo.config.hash), 5); } } ); } }I will adjust all starting points now and afterwards the build scripts (including the npx neo-app repo).
Best regards, Tobi