Last active
June 1, 2020 05:17
-
-
Save dcposch/1f07179a250d43ac667db897de3249fd to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const win = new electron.BrowserWindow(...) | |
// When work makes progress, show the progress bar | |
function onProgress (progess) { | |
// Use values 0 to 1, or -1 to hide the progress bar | |
win.setProgressBar(progress || -1) // Progress bar works on all platforms | |
} | |
// When work completes while the app is in the background, show a badge | |
var numDoneInBackground = 0 | |
function onDone () { | |
var dock = electron.app.dock // Badge works only on Mac | |
if (!dock || win.isFocused()) return | |
numDoneInBackground++ | |
dock.setBadge('' + numDoneInBackground) | |
} | |
// Subscribe to the window focus event. When that happens, hide the badge | |
function onFocus () { | |
numDoneInBackground = 0 | |
dock.setBadge('') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
spotted a tiny mistake in line 4 (progess -> progress)
btw awesome article :D