-
-
Save komplexb/2f5765f78111f07e4d84ce064893431c to your computer and use it in GitHub Desktop.
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
// http://electron.atom.io/docs/api/ipc-main | |
ipc.on('reschedule-notes', (event, arg) => { | |
rescheduleRandomNote(arg) | |
}) | |
app.on('ready', () => { | |
// for reliability refresh scheduled task when computer wakes | |
// http://electron.atom.io/docs/api/power-monitor/#powermonitor | |
electron.powerMonitor.on('resume', () => { | |
log.info('computer awake: refresh schedule') | |
rescheduleRandomNote() | |
}) | |
}) | |
function rescheduleRandomNote (scheduleVal = storeSettings.getItemSync('schedule')) { | |
log.info(`reschedule-notes-to: ${scheduleVal}`) | |
scheduleInstance = scheduleRandomNote(scheduleVal) | |
} |
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
2016-12-28 | 18:28:54:0181 reschedule-notes-to: 9 // i set schedule to morning (9) then put computer to sleep | |
2016-12-28 | 18:29:03:0720 computer awake: refresh schedule | |
2016-12-28 | 18:29:03:0720 canceled: Thu Dec 29 2016 09:00:00 GMT-0500 (EST) // app cancels old schedule of 9 | |
2016-12-28 | 18:29:03:0720 canceled-settings-value: 9 // app cancels old schedule of 9 | |
2016-12-28 | 18:29:03:0720 reschedule-notes-to: */5 * * * * // app should read value from file set in line 1 instead it uses old value from app load |
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
handleSave () { | |
storeSettings.setItemSync('schedule', this.settings.schedule) // this.settings.schedule = 9 | |
// http://electron.atom.io/docs/api/ipc-renderer | |
ipc.send('reschedule-notes', this.settings.schedule) // this.settings.schedule = 9 | |
} |
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
{"key":"schedule","value":"*/5 * * * *"} // initial setting on load |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Event Emitters in Electron: ipcMain.on vs electron.powerMonitor.on
I'm using a method to set a schedule with a value, sometimes this value comes from a settings file, other times it comes from a user selection.
Calling from render.js works, it uses the newly provided value, but calling from electron.js uses the value it obtained when the app loaded, when what I really want it to do is retrieve a new value from
storeSettings.getItemSync('schedule')
.Why does reschedule-notes behave different from resume? Is it because
rescheduleRandomNote(arg)
insidereschedule-notes
is provided a new argument?