Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation unclear for app.makeSingleInstance #4478

Closed
apoco opened this issue Feb 15, 2016 · 7 comments
Closed

Documentation unclear for app.makeSingleInstance #4478

apoco opened this issue Feb 15, 2016 · 7 comments

Comments

@apoco
Copy link
Contributor

apoco commented Feb 15, 2016

One thing is unclear in the documentation for app.makeSingleInstance. The docs say that calling that returns true or false indicating whether the application should continue launching, but it doesn't mention anything about the return value of the callback. The sample shows the callback returning true, but it's not clear whether this return value has a causal affect on the return value of makeSingleInstance. And I've seen other code samples where nothing is returned from the callback at all.

Should the callback to makeSingleInstance return something? If so, what does the return value mean? Should the docs be updated to make this clearer?

@anaisbetts
Copy link
Contributor

@apoco The return value of the callback used to do something but now afaik does nothing particularly useful. Just return true

@apoco
Copy link
Contributor Author

apoco commented Feb 15, 2016

Will returning nothing work just as well? The more I looked into it, the more it looked like it had no effect, but I'm not completely clear on that still.

If it truly does nothing, I humbly propose #4480

@zcbenz
Copy link
Member

zcbenz commented Feb 16, 2016

Closed with #4480.

@zcbenz zcbenz closed this as completed Feb 16, 2016
@thinkdj
Copy link

thinkdj commented Mar 22, 2016


/* Single Instance Check */
var iShouldQuit = app.makeSingleInstance(function(commandLine, workingDirectory) {
    if (mainWindow) {
        if (mainWindow.isMinimized()) mainWindow.restore();
        mainWindow.show();
        mainWindow.focus();
    }
    return true;
});
if(iShouldQuit){app.quit();return;}

@nidhir-systango
Copy link

@thinkdj i have done exactly same,

var iShouldQuit = app.makeSingleInstance(function(commandLine, workingDirectory) {
if (mainWindow) {
if (mainWindow.isMinimized()) mainWindow.restore();
mainWindow.show();
mainWindow.focus();
}
return true;
});
if(iShouldQuit){app.quit();return;}

But when one instance of app is open it do not open new intsance(which is correct),but is not restoring the current instance(which is Minimized)
Any idea?

@MarshallOfSound
Copy link
Member

@nidhir-systango Your code looks correct but I must say again 👍

GitHub issues are for feature requests and bug reports, questions about using Electron should be directed to the community or to the Slack Channel.

You are much more likely to get an answer on Slack or in the Discussion Forums than posting on a several month old closed issue.

@dominikfiala
Copy link

Just run into this issue when trying to make makeSingleInstance work, was getting Error: Object has been destroyed untill i added return after app.quit(), so i vote for updating the docs at https://electron.atom.io/docs/api/app/#appmakesingleinstancecallback

if (shouldQuit) {
  app.quit()
  return // super important
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants