Skip to content

Commit 8f5bab0

Browse files
committed
Fixed #10 Fire an event when server side settings are changed
@ejsmith Do you like this? I'm mixed
1 parent 8edb61c commit 8f5bab0

8 files changed

+36
-11
lines changed

Diff for: bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "exceptionless",
3-
"version": "0.2.1",
3+
"version": "0.3.0",
44
"description": "JavaScript client for Exceptionless",
55
"license": "Apache",
66
"main": "dist/exceptionless.js",

Diff for: dist/exceptionless.d.ts

+3
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ export interface IConfigurationSettings {
9494
}
9595
export declare class SettingsManager {
9696
private static _configPath;
97+
private static _handlers;
98+
private static changed(config);
99+
static onChanged(handler: (config: Configuration) => void): void;
97100
static applySavedServerSettings(config: Configuration): void;
98101
private static getSavedServerSettings(config);
99102
static checkVersion(version: number, config: Configuration): void;

Diff for: dist/exceptionless.js

+13-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: dist/exceptionless.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: dist/exceptionless.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: dist/exceptionless.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "exceptionless",
3-
"version": "0.2.1",
3+
"version": "0.3.0",
44
"description": "JavaScript client for Exceptionless",
55
"license": "Apache",
66
"main": "dist/exceptionless.es5.js",

Diff for: src/configuration/SettingsManager.ts

+14-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,22 @@ import { Utils } from '../Utils';
44

55
export class SettingsManager {
66
private static _configPath:string = 'ex-server-settings.json';
7+
private static _handlers:{ (config:Configuration):void }[] = [];
8+
9+
private static changed(config:Configuration) {
10+
for (var index = 0; index < this._handlers.length; index++) {
11+
this._handlers[index](config);
12+
}
13+
}
14+
15+
public static onChanged(handler:(config:Configuration) => void) {
16+
!!handler && this._handlers.push(handler);
17+
}
718

819
public static applySavedServerSettings(config:Configuration):void {
9-
config.settings = Utils.merge(config.settings, this.getSavedServerSettings(config));
1020
config.log.info('Applying saved settings.');
11-
// TODO: Fire on changed event.
21+
config.settings = Utils.merge(config.settings, this.getSavedServerSettings(config));
22+
this.changed(config);
1223
}
1324

1425
private static getSavedServerSettings(config:Configuration):Object {
@@ -55,7 +66,7 @@ export class SettingsManager {
5566
config.storage.save(this._configPath, response.settings);
5667

5768
config.log.info('Updated settings');
58-
// TODO: Fire on changed event.
69+
this.changed(config);
5970
});
6071
}
6172
}

0 commit comments

Comments
 (0)