Commit 4d63b576 by Torkel Ödegaard

tech(): put in a real event emitter instead of rxjs based on that was broken

parent 44cf66d7
# 3.0.0-beta3 (unreleased) # 3.0.0-beta2 (unreleased)
### Bug fixes
* **Postgres**: Fixed page render crash when using postgres, fixes [#4558](https://github.com/grafana/grafana/issues/4558)
* **Table panel**: Fixed table panel bug when trying to show annotations in table panel, fixes [#4563](https://github.com/grafana/grafana/issues/4563)
* **App Config**: Fixed app config issue showing content of other app config, fixes [#4575](https://github.com/grafana/grafana/issues/4575)
* **Graph Panel**: Fixed legend option max not updating, fixes [#4601](https://github.com/grafana/grafana/issues/4601)
* **Graph Panel**: Fixed issue where newly added graph panels shared same axes config, fixes [#4582](https://github.com/grafana/grafana/issues/4582)
# 3.0.0-beta2 (2016-04-04)
### New Features (introduces since 3.0-beta1) ### New Features (introduces since 3.0-beta1)
* **Preferences**: Set home dashboard on user and org level, closes [#1678](https://github.com/grafana/grafana/issues/1678) * **Preferences**: Set home dashboard on user and org level, closes [#1678](https://github.com/grafana/grafana/issues/1678)
...@@ -18,9 +9,8 @@ ...@@ -18,9 +9,8 @@
* **Dashboard**: Fixed dashboard panel layout for mobile devices, fixes [#4529](https://github.com/grafana/grafana/issues/4529) * **Dashboard**: Fixed dashboard panel layout for mobile devices, fixes [#4529](https://github.com/grafana/grafana/issues/4529)
* **Table Panel**: Fixed issue with table panel sort, fixes [#4532](https://github.com/grafana/grafana/issues/4532) * **Table Panel**: Fixed issue with table panel sort, fixes [#4532](https://github.com/grafana/grafana/issues/4532)
* **Page Load Crash**: A Datasource with null jsonData would make Grafana fail to load page, fixes [#4536](https://github.com/grafana/grafana/issues/4536) * **Page Load Crash**: A Datasource with null jsonData would make Grafana fail to load page, fixes [#4536](https://github.com/grafana/grafana/issues/4536)
* **Metrics tab**: Fix for missing datasource name in datasource selector, fixes [#4540](https://github.com/grafana/grafana/issues/4540) * **Metrics tab**: Fix for missing datasource name in datasource selector, fixes [#4541](https://github.com/grafana/grafana/issues/4540)
* **Graph**: Fix legend in table mode with series on right-y axis, fixes [#4551](https://github.com/grafana/grafana/issues/4551), [#1145](https://github.com/grafana/grafana/issues/1145) * **Graph**: Fix legend in table mode with series on right-y axis, fixes [#4551](https://github.com/grafana/grafana/issues/4551), [#1145](https://github.com/grafana/grafana/issues/1145)
* **Password**: Password reset link/page did not work, fixes [#4542](https://github.com/grafana/grafana/issues/4542)
# 3.0.0-beta1 (2016-03-31) # 3.0.0-beta1 (2016-03-31)
......
...@@ -67,6 +67,7 @@ ...@@ -67,6 +67,7 @@
}, },
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"eventemitter3": "^1.2.0",
"grunt-jscs": "~1.5.x", "grunt-jscs": "~1.5.x",
"grunt-sass-lint": "^0.1.0", "grunt-sass-lint": "^0.1.0",
"grunt-sync": "^0.4.1", "grunt-sync": "^0.4.1",
......
///<reference path="../../headers/common.d.ts" /> ///<reference path="../../headers/common.d.ts" />
import {Subject} from 'vendor/npm/rxjs/Subject'; import EventEmitter from 'eventemitter3';
var hasOwnProp = {}.hasOwnProperty; var hasOwnProp = {}.hasOwnProperty;
...@@ -9,48 +9,27 @@ function createName(name) { ...@@ -9,48 +9,27 @@ function createName(name) {
} }
export class Emitter { export class Emitter {
subjects: any; emitter: any;
constructor() { constructor() {
this.subjects = {}; this.emitter = new EventEmitter();
} }
emit(name, data?) { emit(name, data?) {
var fnName = createName(name); this.emitter.emit(name, data);
this.subjects[fnName] || (this.subjects[fnName] = new Subject());
this.subjects[fnName].next(data);
} }
on(name, handler, scope?) { on(name, handler, scope?) {
var fnName = createName(name); this.emitter.on(name, handler);
this.subjects[fnName] || (this.subjects[fnName] = new Subject());
var subscription = this.subjects[fnName].subscribe(handler);
if (scope) { if (scope) {
scope.$on('$destroy', function() { scope.$on('$destroy', function() {
subscription.unsubscribe(); this.emitter.off(name, handler);
}); });
} }
return subscription;
};
off(name, handler) {
var fnName = createName(name);
if (this.subjects[fnName]) {
this.subjects[fnName].dispose();
delete this.subjects[fnName];
}
} }
dispose() { off(name, handler) {
var subjects = this.subjects; this.emitter.off(name, handler);
for (var prop in subjects) {
if (hasOwnProp.call(subjects, prop)) {
subjects[prop].dispose();
}
}
this.subjects = {};
} }
} }
...@@ -47,3 +47,8 @@ declare module 'tether-drop' { ...@@ -47,3 +47,8 @@ declare module 'tether-drop' {
var config: any; var config: any;
export default config; export default config;
} }
declare module 'eventemitter3' {
var config: any;
export default config;
}
...@@ -4,6 +4,7 @@ System.config({ ...@@ -4,6 +4,7 @@ System.config({
paths: { paths: {
'remarkable': 'vendor/npm/remarkable/dist/remarkable.js', 'remarkable': 'vendor/npm/remarkable/dist/remarkable.js',
'tether': 'vendor/npm/tether/dist/js/tether.js', 'tether': 'vendor/npm/tether/dist/js/tether.js',
'eventemitter3': 'vendor/npm/eventemitter3/index.js',
'tether-drop': 'vendor/npm/tether-drop/dist/js/drop.js', 'tether-drop': 'vendor/npm/tether-drop/dist/js/drop.js',
'moment': 'vendor/moment.js', 'moment': 'vendor/moment.js',
"jquery": "vendor/jquery/dist/jquery.js", "jquery": "vendor/jquery/dist/jquery.js",
...@@ -55,5 +56,9 @@ System.config({ ...@@ -55,5 +56,9 @@ System.config({
deps: ['jquery'], deps: ['jquery'],
exports: 'angular', exports: 'angular',
}, },
'vendor/npm/eventemitter3/index.js': {
format: 'cjs',
exports: 'EventEmitter'
},
} }
}); });
...@@ -52,6 +52,7 @@ button.close { ...@@ -52,6 +52,7 @@ button.close {
.pull-right { .pull-right {
float: right !important; float: right !important;
} }
.pull-left { .pull-left {
float: left !important; float: left !important;
} }
......
...@@ -24,12 +24,12 @@ describe("Emitter", () => { ...@@ -24,12 +24,12 @@ describe("Emitter", () => {
expect(sub2Called).to.be(true); expect(sub2Called).to.be(true);
}); });
it('should handle errors', () => { it.only('should handle errors', () => {
var events = new Emitter(); var events = new Emitter();
var sub1Called = 0; var sub1Called = 0;
var sub2Called = 0; var sub2Called = 0;
var sub1 = events.on('test', () => { events.on('test', () => {
sub1Called++; sub1Called++;
throw "hello"; throw "hello";
}); });
...@@ -41,8 +41,8 @@ describe("Emitter", () => { ...@@ -41,8 +41,8 @@ describe("Emitter", () => {
try { events.emit('test', null); } catch (_) { } try { events.emit('test', null); } catch (_) { }
try { events.emit('test', null); } catch (_) {} try { events.emit('test', null); } catch (_) {}
expect(sub1Called).to.be(1); expect(sub1Called).to.be(2);
expect(sub2Called).to.be(1); expect(sub2Called).to.be(0);
}); });
}); });
}); });
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
baseURL: '/base/', baseURL: '/base/',
defaultJSExtensions: true, defaultJSExtensions: true,
paths: { paths: {
'eventemitter3': 'vendor/npm/eventemitter3/index.js',
'tether': 'vendor/npm/tether/dist/js/tether.js', 'tether': 'vendor/npm/tether/dist/js/tether.js',
'tether-drop': 'vendor/npm/tether-drop/dist/js/drop.js', 'tether-drop': 'vendor/npm/tether-drop/dist/js/drop.js',
'moment': 'vendor/moment.js', 'moment': 'vendor/moment.js',
...@@ -58,7 +59,11 @@ ...@@ -58,7 +59,11 @@
'vendor/angular-mocks/angular-mocks.js': { 'vendor/angular-mocks/angular-mocks.js': {
format: 'global', format: 'global',
deps: ['angular'], deps: ['angular'],
} },
'vendor/npm/eventemitter3/index.js': {
format: 'cjs',
exports: 'EventEmitter'
},
} }
}); });
......
...@@ -19,10 +19,7 @@ module.exports = function(config) { ...@@ -19,10 +19,7 @@ module.exports = function(config) {
cwd: './node_modules', cwd: './node_modules',
expand: true, expand: true,
src: [ src: [
'angular2/bundles/*.js', 'eventemitter3/*.js',
'angular2/*.d.ts',
'angular2/typings/**/*',
'angular2/manual_typings/**/*',
'systemjs/dist/*.js', 'systemjs/dist/*.js',
'es6-promise/**/*', 'es6-promise/**/*',
'es6-shim/*.js', 'es6-shim/*.js',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment