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)
### 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)
# 3.0.0-beta2 (unreleased)
### 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)
......@@ -18,9 +9,8 @@
* **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)
* **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)
* **Password**: Password reset link/page did not work, fixes [#4542](https://github.com/grafana/grafana/issues/4542)
# 3.0.0-beta1 (2016-03-31)
......
......@@ -67,6 +67,7 @@
},
"license": "Apache-2.0",
"dependencies": {
"eventemitter3": "^1.2.0",
"grunt-jscs": "~1.5.x",
"grunt-sass-lint": "^0.1.0",
"grunt-sync": "^0.4.1",
......
///<reference path="../../headers/common.d.ts" />
import {Subject} from 'vendor/npm/rxjs/Subject';
import EventEmitter from 'eventemitter3';
var hasOwnProp = {}.hasOwnProperty;
......@@ -9,48 +9,27 @@ function createName(name) {
}
export class Emitter {
subjects: any;
emitter: any;
constructor() {
this.subjects = {};
this.emitter = new EventEmitter();
}
emit(name, data?) {
var fnName = createName(name);
this.subjects[fnName] || (this.subjects[fnName] = new Subject());
this.subjects[fnName].next(data);
this.emitter.emit(name, data);
}
on(name, handler, scope?) {
var fnName = createName(name);
this.subjects[fnName] || (this.subjects[fnName] = new Subject());
var subscription = this.subjects[fnName].subscribe(handler);
this.emitter.on(name, handler);
if (scope) {
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() {
var subjects = this.subjects;
for (var prop in subjects) {
if (hasOwnProp.call(subjects, prop)) {
subjects[prop].dispose();
}
}
this.subjects = {};
off(name, handler) {
this.emitter.off(name, handler);
}
}
......@@ -47,3 +47,8 @@ declare module 'tether-drop' {
var config: any;
export default config;
}
declare module 'eventemitter3' {
var config: any;
export default config;
}
......@@ -4,6 +4,7 @@ System.config({
paths: {
'remarkable': 'vendor/npm/remarkable/dist/remarkable.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',
'moment': 'vendor/moment.js',
"jquery": "vendor/jquery/dist/jquery.js",
......@@ -55,5 +56,9 @@ System.config({
deps: ['jquery'],
exports: 'angular',
},
'vendor/npm/eventemitter3/index.js': {
format: 'cjs',
exports: 'EventEmitter'
},
}
});
......@@ -52,6 +52,7 @@ button.close {
.pull-right {
float: right !important;
}
.pull-left {
float: left !important;
}
......
......@@ -24,12 +24,12 @@ describe("Emitter", () => {
expect(sub2Called).to.be(true);
});
it('should handle errors', () => {
it.only('should handle errors', () => {
var events = new Emitter();
var sub1Called = 0;
var sub2Called = 0;
var sub1 = events.on('test', () => {
events.on('test', () => {
sub1Called++;
throw "hello";
});
......@@ -41,8 +41,8 @@ describe("Emitter", () => {
try { events.emit('test', null); } catch (_) { }
try { events.emit('test', null); } catch (_) {}
expect(sub1Called).to.be(1);
expect(sub2Called).to.be(1);
expect(sub1Called).to.be(2);
expect(sub2Called).to.be(0);
});
});
});
......
......@@ -10,6 +10,7 @@
baseURL: '/base/',
defaultJSExtensions: true,
paths: {
'eventemitter3': 'vendor/npm/eventemitter3/index.js',
'tether': 'vendor/npm/tether/dist/js/tether.js',
'tether-drop': 'vendor/npm/tether-drop/dist/js/drop.js',
'moment': 'vendor/moment.js',
......@@ -58,7 +59,11 @@
'vendor/angular-mocks/angular-mocks.js': {
format: 'global',
deps: ['angular'],
}
},
'vendor/npm/eventemitter3/index.js': {
format: 'cjs',
exports: 'EventEmitter'
},
}
});
......
......@@ -19,10 +19,7 @@ module.exports = function(config) {
cwd: './node_modules',
expand: true,
src: [
'angular2/bundles/*.js',
'angular2/*.d.ts',
'angular2/typings/**/*',
'angular2/manual_typings/**/*',
'eventemitter3/*.js',
'systemjs/dist/*.js',
'es6-promise/**/*',
'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