electron-userland / electron-json-storage

:package: Easily write and read user settings in Electron apps
1.44k stars 80 forks source link

Unsure where to insert the set function #21

Closed ohalligan closed 7 years ago

ohalligan commented 8 years ago

I want to store a list variable called notebookList {notebookOne,notebookTwo,notebookThree}

How do I modify this code:

const storage = require('electron-json-storage');

storage.set('foobar', { foo: 'bar' }, function(error) {
  if (error) throw error;
});

Also, do I insert it anywhere in the index.html file?

jviotti commented 8 years ago

Hi @ohalligan ,

I want to store a list variable called notebookList {notebookOne,notebookTwo,notebookThree} How do I modify this code:

I'm not sure I understand the question. Should an array of object suffice?

storage.set('mydata', {
  notebooks: [
    {
      name: 'notebookOne'
    },
    {
      name: 'notebookOne'
    },
    {
      name: 'notebookOne'
    }
  ]
}, function(error) {
  if (error) throw error;
});

Also, do I insert it anywhere in the index.html file?

You can call the functions from anywhere in the renderer process!

jviotti commented 7 years ago

I'm going to close this as resolved. Please re-open if you have any other questions!