The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

xboxremote (6) [Avatar] Offline
#1
I feel like I'm missing something here - why would you do windows.add(newWindow) twice in the createWindow function? Here's what I'm talking about (line 3 and line 16):

const createWindow = exports.createWindow = () => {
    let newWindow = new BrowserWindow({show: false});
    windows.add(newWindow);

    newWindow.loadURL(`file://${__dirname}/index.html`);

    newWindow.once('ready-to-show', () => {
        newWindow.show();
    });

    newWindow.on('closed', () => {
        windows.delete(newWindow);
        newWindow = null;
    });

    windows.add(newWindow);

    return newWindow;
};


I debugged it, and it looks like it doesn't add it twice to the Set somehow, but I don't get why we call that line twice.

Thanks!
Steve Kinney (33) [Avatar] Offline
#2
Awesome catch! Thank you so, so much! I just fixed the manuscript. If you didn't catch that one, it might have gone to production.

You're write, it won't cause an error, but it is a useless duplication.
xboxremote (6) [Avatar] Offline
#3
Steve Kinney wrote:Awesome catch! Thank you so, so much! I just fixed the manuscript. If you didn't catch that one, it might have gone to production.

You're write, it won't cause an error, but it is a useless duplication.


No prob! I'm just glad I wasn't missing something smilie

- Nick