0
I’m passing my app made in electronjs (nodejs) to the MVC standard and found 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 methods close();
and show();
in my windows, for they are given as undefined
- which is perfectly logical, since it was the standard state I passed on to them.
How do I update this property after running the Function responsible for storing the BrowserWindow
in it?
I keep receiving as Undefined, Thiago :/ And how to keep the state to an instance of the module? Sorry, but I am layman and I started today with MVC and Nodejs standard.
– Daniel Bonifácio
Daniel, you changed at my suggestion in the two modules (controllers/loading-controller and controllers/main-controller)?
– Thiago Barcala
Now that I saw that I needed to match the exported window with the window that was running on Function, and it worked that is a beauty! Thank you, Thiago.
– Daniel Bonifácio