Skip to content

Latest commit

 

History

History
83 lines (54 loc) · 2.56 KB

File metadata and controls

83 lines (54 loc) · 2.56 KB

electron-settings

This is a fork version of electron-settings with some below changes

  • Use lodash to simplify the code. Make code easier to understand
  • Use memory watcher instead of file watcher. Make watcher more efficient, we do not have to read file everytime we want to get a property
  • Support unwatch api that allow user to unregister his watcher

Please note: because this library watches on memory instead of file. Please not that the change event is not fired when you change value directly on setting file

Install

$ npm install --save git+https://github.com/anyTV/electron-settings.git

Demo

const { app } = require('electron');
const settings = require('electron-settings');

app.on('ready', () => {

  // call method initialize() to start reading setting file and load into memory object
  settings.initialize()
  
  settings.set('name', {
    first: 'Cosmo',
    last: 'Kramer'
  });

  settings.get('name.first');
  // => "Cosmo"

  settings.has('name.middle');
  // => false
});

⚠️ Please note: Any and all interaction with electron-settings must be executed after the Electron app has fired the ready event, otherwise your app may encounter unexpected errors or data loss.

Resources

Having trouble? Get help on Gitter.