
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
electron-app-settings
Advanced tools
An easy-to-use, efficient, and multi-process safe settings framework for Electron that presumes a single application configuration file.
Written to allow settings to be shared between the main process and renderer processes through ipcMain and ipcRenderer communication. The main process acts as the master to all renderer processes, loading the initial configuration file, managing synchronization, and the saving of the configuration on application quit.
Compatible with electron-config generated configuration files.
$ npm install electron-app-settings --save
electron-app-settings
can simply be required wherever it is needed, regardless of if it has been loaded in the main process or not, as the module will automatically handle setting itself up in the main process. If using a packer, it may be necessary to disable the use of remote.require
via the NO_REMOTE_REQUIRE
environment variable. If NO_REMOTE_REQUIRE
is set, then you must ensure that the main process requires electron-app-settings
as well as the renderer process.
The configuration file is presumed to be located at "userData/Settings" and will be saved on application quit.
// MAIN PROCESS
const settings = require('electron-app-settings');
settings.set('cat', {
name: 'Cat',
limbs: 4,
fuzzy: true
});
settings.get('cat.name');
// => "Cat"
settings.has('cat.bark');
// => false
/* Object-only merge-style defaults */
settings.set({
{ dog: {
name: "Dog",
tail: true
}
}, true);
settings.get('cat');
// => {name: "Cat", limbs: 4, fuzzy: true, tail: true}
settings.get('dog');
// => {name: "Dog", tail: true}
// RENDERER PROCESS
const settings = require('electron-app-settings');
// ... on app-ready
settings.get('cat');
// => {name: "Cat", limbs: 4, fuzzy: true, tail: true}
electron-app-settings
also has a Promise-style API accessible through the promises
property of the settings object returned via require('electron-app-settings')
. It functions exactly the same as the normal API with any return values being returned through the Promise's resolve callback. Access through the promises interface ensures that full renderer to main process IPC communication has already been completed.
// RENDERER PROCESS
const settings = require('electron-app-settings');
// ... somewhere in an async function
await settings.promises.get('cat');
// => {name: "Cat", limbs: 4, fuzzy: true, tail: true}
FAQs
Simple IPC-based settings framework for Electron
We found that electron-app-settings demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.