diff options
author | Valentin Popov <info@valentineus.link> | 2019-08-20 13:51:06 +0300 |
---|---|---|
committer | Valentin Popov <info@valentineus.link> | 2019-08-20 13:51:06 +0300 |
commit | 9c57d101f0181aa134190edb0b2e7aabdba1151f (patch) | |
tree | 41e2405204d001490ba76e272bc5d11020a2c357 /example/application/src/utils | |
parent | b3461bdcc0462bda7fad46b02f8307a0bc1166cd (diff) | |
download | electron-hot-reload-9c57d101f0181aa134190edb0b2e7aabdba1151f.tar.xz electron-hot-reload-9c57d101f0181aa134190edb0b2e7aabdba1151f.zip |
Added example application
Signed-off-by: Valentin Popov <info@valentineus.link>
Diffstat (limited to 'example/application/src/utils')
-rw-r--r-- | example/application/src/utils/get-json.js | 12 | ||||
-rw-r--r-- | example/application/src/utils/reloader.js | 20 |
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() }) +}) |