electron-settings
Advanced tools
Comparing version 1.0.4 to 1.1.0
@@ -7,2 +7,3 @@ Events | ||
* [`save`][event_save] | ||
* [`create`][event_create] | ||
@@ -86,10 +87,33 @@ | ||
*** | ||
create | ||
----- | ||
**`settings.on('create', handler)`** | ||
Called when the settings file has been create on disk, e.g. on first run. | ||
**Example** | ||
```js | ||
function handleCreate() { | ||
console.log('Settings file created'); | ||
} | ||
settings.on('create', handleCreate); | ||
``` | ||
[event_change]: #change | ||
[event_error]: #error | ||
[event_save]: #save | ||
[event_create]: #create |
@@ -81,2 +81,11 @@ /** | ||
/** | ||
* Internal created event handler. | ||
* | ||
* @see _handleCreate | ||
* @type {Function} | ||
* @private | ||
*/ | ||
this._onCreate = this._handleCreate.bind(this); | ||
/** | ||
* Internal change event handler. | ||
@@ -175,2 +184,3 @@ * | ||
fs.outputJsonSync(configFilePath, {}); | ||
this._emitCreateEvent(); | ||
@@ -205,2 +215,3 @@ debug('config file generated at ' + configFilePath); | ||
_setupInternalEventBindings() { | ||
this.on(Settings.Events.CREATE, this._onCreated); | ||
this.on(Settings.Events.CHANGE, this._onChange); | ||
@@ -212,2 +223,11 @@ this.on(Settings.Events.SAVE, this._onSave); | ||
/** | ||
* Called when the "created" event fires. | ||
* | ||
* @private | ||
*/ | ||
_handleCreate() { | ||
debug('settings file created'); | ||
} | ||
/** | ||
* Called when the "change" event fires. This checks the watch list for any | ||
@@ -541,2 +561,12 @@ * watched keys and calls their respective watch handlers if the changed key | ||
/** | ||
* Triggers the "created" event. | ||
* | ||
* @emits ElectronSettings#save | ||
* @private | ||
*/ | ||
_emitCreateEvent() { | ||
this.emit(Settings.Events.CREATE); | ||
} | ||
/** | ||
* Triggers the "change" event. | ||
@@ -582,2 +612,3 @@ * | ||
this.removeListener(Settings.Events.CREATE, this._onCreate); | ||
this.removeListener(Settings.Events.CHANGE, this._onChange); | ||
@@ -592,2 +623,3 @@ this.removeListener(Settings.Events.SAVE, this._onSave); | ||
this._debouncedSave = null; | ||
this._onCreate = null; | ||
this._onChange = null; | ||
@@ -629,2 +661,3 @@ this._onError = null; | ||
Settings.Events = { | ||
CREATE: 'create', | ||
CHANGE: 'change', | ||
@@ -631,0 +664,0 @@ ERROR: 'error', |
{ | ||
"name": "electron-settings", | ||
"version": "1.0.4", | ||
"version": "1.1.0", | ||
"description": "User settings manager for Electron", | ||
@@ -15,4 +15,18 @@ "main": "index.js", | ||
], | ||
"repository": "https://github.com/nathanbuchar/electron-settings", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/nathanbuchar/electron-settings" | ||
}, | ||
"author": "Nathan Buchar <hello@nathanbuchar.com>", | ||
"contributors": [ | ||
{ | ||
"name": "Nathan Buchar", | ||
"email": "hello@nathanbuchar.com", | ||
"web": "http://nathanbuchar,com/" | ||
}, | ||
{ | ||
"name": "Kai Eichinger", | ||
"email": "kai.eichinger@outlook.com" | ||
} | ||
], | ||
"license": "ISC", | ||
@@ -19,0 +33,0 @@ "dependencies": { |
@@ -57,5 +57,6 @@ ElectronSettings | ||
Authors | ||
Contributors | ||
------- | ||
* [Nathan Buchar](mailto:hello@nathanbuchar.com) | ||
* [Kai Eichinger](mailto:kai.eichinger@outlook.com) | ||
@@ -62,0 +63,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
51889
1349
72
2