I'm passing my electronjs app (nodejs) to the MVC standard and I encountered a problem when updating an exported property.
Example of my application.js
:
// Importa os módulos privados
const config = require('./config/config');
const loading = require('./controllers/loading-controller');
const main = require('./controllers/main-controller');
app.on('ready', function () {
loading.createWindow(__dirname);
main.createWindow(__dirname);
setTimeout(function(){
loading.window.close();
main.window.show();
}, 3000);
});
Example of my loading-controller.js
:
// Importa o model
const loading = require('../models/loading');
let loadingWindow;
module.exports = {
createWindow: function (dir) {
loadingWindow = new BrowserWindow(loading);
},
window: loadingWindow
}
The problem occurs when I try to execute the close();
and show();
methods in my windows, because they are given as undefined
- which is perfectly logical since it was the default state I passed to them. p>
How do I update this property after running the function responsible for storing the BrowserWindow
in it?