Move the addon startup logic to addons.js

Moved the graphite logic to new graphs.js

The settings code now does change notification itself. Over time,
it makes sense to just having settings code do this for everything
and not have this change listener logic. This lets us:
* Maybe the settings can only return based on final handler result
* All dependant modules otherwise have to "init"ed to listen on startup
* Easier to test those handlers without having to actually change the
  setting (since they will now be in "exports" naturally)

Also, maybe someday with this abstraction we can allow apps to have their
own isolated databases etc
This commit is contained in:
Girish Ramakrishnan
2018-10-16 14:07:41 -07:00
parent bbc121399e
commit 045cfeeb0d
4 changed files with 251 additions and 240 deletions

View File

@@ -60,7 +60,8 @@ exports = module.exports = {
events: null
};
var assert = require('assert'),
var addons = require('./addons.js'),
assert = require('assert'),
backups = require('./backups.js'),
BackupsError = backups.BackupsError,
config = require('./config.js'),
@@ -397,9 +398,7 @@ function setPlatformConfig(platformConfig, callback) {
settingsdb.set(exports.PLATFORM_CONFIG_KEY, JSON.stringify(platformConfig), function (error) {
if (error) return callback(new SettingsError(SettingsError.INTERNAL_ERROR, error));
exports.events.emit(exports.PLATFORM_CONFIG_KEY, platformConfig);
callback(null);
addons.updateAddonConfig(platformConfig, callback);
});
}