aboutsummaryrefslogtreecommitdiff
path: root/example/application/src/utils
diff options
context:
space:
mode:
authorValentin Popov <info@valentineus.link>2019-08-22 00:12:17 +0300
committerGitHub <noreply@github.com>2019-08-22 00:12:17 +0300
commit6d5cb2611be73e4c3b0787ac00fe28e4c243417e (patch)
tree5b65999c40a916d0e4bb5f878b30cee236045e94 /example/application/src/utils
parent03dd1ac6af558886acae1296832459827ade54c3 (diff)
parent8147b911dec725f50fb79e22dd149e13eca02d81 (diff)
downloadelectron-hot-reload-6d5cb2611be73e4c3b0787ac00fe28e4c243417e.tar.xz
electron-hot-reload-6d5cb2611be73e4c3b0787ac00fe28e4c243417e.zip
Merge pull request #1 from valentineus/develop
Develop
Diffstat (limited to 'example/application/src/utils')
-rw-r--r--example/application/src/utils/get-json.js12
-rw-r--r--example/application/src/utils/reloader.js20
2 files changed, 32 insertions, 0 deletions
diff --git a/example/application/src/utils/get-json.js b/example/application/src/utils/get-json.js
new file mode 100644
index 0000000..18f4403
--- /dev/null
+++ b/example/application/src/utils/get-json.js
@@ -0,0 +1,12 @@
+import { app, ipcMain } from 'electron'
+import jsonfile from 'jsonfile'
+import path from 'path'
+
+ipcMain.on('get:json', async (event) => {
+ const tempDir = path.join(app.getAppPath(), 'temp')
+
+ const main = await jsonfile.readFile(path.join(tempDir, 'main.json'))
+ const renderer = await jsonfile.readFile(path.join(tempDir, 'renderer.json'))
+
+ event.sender.send('get:json:result', { main, renderer })
+})
diff --git a/example/application/src/utils/reloader.js b/example/application/src/utils/reloader.js
new file mode 100644
index 0000000..ad78496
--- /dev/null
+++ b/example/application/src/utils/reloader.js
@@ -0,0 +1,20 @@
+import { app, ipcMain } from 'electron'
+import jsonfile from 'jsonfile'
+import path from 'path'
+
+import { mainReloader, rendererReloader } from '../../../../dist'
+
+const tempDir = path.join(app.getAppPath(), 'temp')
+const tempMain = path.join(tempDir, 'main.json')
+const tempRend = path.join(tempDir, 'renderer.json')
+
+mainReloader(tempMain)
+rendererReloader(tempRend)
+
+ipcMain.on('reload:main', async () => {
+ await jsonfile.writeFile(tempMain, { time: Date.now() })
+})
+
+ipcMain.on('reload:renderer', async () => {
+ await jsonfile.writeFile(tempRend, { time: Date.now() })
+})