javascript - No communication between electron app and user AddData on production - TagMerge
4No communication between electron app and user AddData on productionNo communication between electron app and user AddData on production

No communication between electron app and user AddData on production

Asked 1 years ago
0
4 answers

Looking at your code, I suspect that your /config folder does not exists when running your application. So, all your variables isSizeDir, isPosDir, etc. are false and stays false even after creating the folder on line 17.

I would move the /config folder creation after line 11.

Source: link

0

You should take a look at the electron-json-storage package. The package will handle where to put the persisent data depending on the user OS system, and the JSON parsing. You just need to call the package with whatever JS Object you want to store.

I am using this package in my differents electron projects, and it really makes it easy. I recommand using it instead of struggling with the 'fs' Node API.

Source: link

0

Got it working now.

So basically. app.getPath('userData') gives you path up into electron app dir so I have been writing into my electron app directory.

But using app.getPath('appData') get path unto electron app directory level and does not include it. hence won't be packages by electron-builder and it always be in the pc app dir.

const appDir = app.getPath('appData');

instead of

const appDir = app.getPath('userData');

I got this from Jay. chatted with him earlier. His youtube channel - ithinktechnologies

Thanks @Guillaume and @Dony for your time. Means a lot to me

Source: link

0

To get started, we're going to establish the IPC main process in our /main.js file:
// Other const's removed for brevity

const ipc = require('electron').ipcMain
Next, at the very bottom of this file, let's add the following:
ipc.on('update-notify-value', function (event, arg) {
  win.webContents.send('targetPriceVal', arg)
})
Next, let's integrate the IPC Renderer process into our /src/add.js file:
// Other const's removed for brevity

const ipc = electron.ipcRenderer
Then, at the bottom of this file, add:
const updateBtn = document.getElementById('updateBtn')

updateBtn.addEventListener('click', function () {
  ipc.send('update-notify-value', document.getElementById('notifyVal').value)

  // Close this window
  var window = remote.getCurrentWindow();
  window.close();
})
We also have to integrate the IPC Renderer process into /src/index.html to receive & set the message sent from IPC Main in main.js:
// Other const's removed for brevity
const ipc = electron.ipcRenderer

var price = document.querySelector('h1')

// Add these two variables
var targetPriceVal;
var targetPrice = document.getElementById('targetPrice')

Source: link

Recent Questions on javascript

    Programming Languages