Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: new makeSingleInstance API (#12782)
* Refactor app.makeSingleInstance * new API `app.isPrimaryInstance()` * new API `app.isSingleInstance()` * new event `app.on('second-instance')` * deprecated old syntax `app.makeSingleInstance(cb)` * deprecated old syntax of `app.makeSingleInstance() --> bool` in favor of `app.isPrimaryInstance()` * Fix spec, we don't need process.nextTick hacks any more * Make deprecation TODO for the return value of makeSingleInstance * Refactor makeSingleInstance to requestSingleInstanceLock and add appropriate deprecation comments * I swear this isn't tricking the linter * Make const * Add deprecation warnings for release, and add to planned-breaking-changes BREAKING CHANGE
- Loading branch information
1 parent
9c8952a
commit 5b5c161
Showing
9 changed files
with
176 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const {app} = require('electron') | ||
|
||
app.once('ready', () => { | ||
console.log('started') // ping parent | ||
}) | ||
|
||
const shouldExit = app.makeSingleInstance(() => { | ||
setImmediate(() => app.exit(0)) | ||
}) | ||
|
||
if (shouldExit) { | ||
app.exit(1) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "electron-app-singleton", | ||
"main": "main.js" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters