Skip to content

anyTV/electron-settings

 
 

Repository files navigation

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.

About

📝 A simple persistent user settings framework for Electron.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%