data-updater
Advanced tools
Comparing version 2.1.0 to 2.2.0
@@ -82,4 +82,4 @@ var _ = require('lodash'); | ||
this._updating = false; | ||
this.emit('error', err); | ||
this._mayBeEmitFirstUpdate(err); | ||
this.emit('error', err); | ||
this._scheduleUpdate(); | ||
@@ -98,4 +98,4 @@ }; | ||
this._updating = false; | ||
this._mayBeEmitFirstUpdate(); | ||
this.emit('update', data); | ||
this._mayBeEmitFirstUpdate(null); | ||
this._scheduleUpdate(); | ||
@@ -102,0 +102,0 @@ }; |
{ | ||
"name": "data-updater", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -12,18 +12,26 @@ # data-updater | ||
```js | ||
var DataUpdater = require('data-updater'); | ||
var dataUpdater = require('data-updater'); | ||
var dataUpdater = new DataUpdater('path/to/data.json', 1000); | ||
var updater = dataUpdater.fromFile('path/to/data.json', 1000); | ||
dataUpdater.on('error', function(err) { | ||
updater.on('error', function(err) { | ||
// Runs if an error occurs to read the data file | ||
}); | ||
dataUpdater.on('old', function() { | ||
updater.on('old', function() { | ||
// Runs when data file was not updated since last attempt | ||
}); | ||
dataUpdater.on('update', function(data) { | ||
updater.on('update', function(data) { | ||
// Runs when data file was updated sice last attempt | ||
}) | ||
}); | ||
update.on('first-update', function(err) { | ||
// Runs after first update attempt, can be unsuccessful | ||
}); | ||
update.on('first-successful-update', function() { | ||
// Runs after first successful update attempt | ||
}); | ||
``` |
8204
37