Skip to content

Commit 4d63b57

Browse files
committed
tech(): put in a real event emitter instead of rxjs based on that was broken
1 parent 44cf66d commit 4d63b57

File tree

9 files changed

+33
-50
lines changed

9 files changed

+33
-50
lines changed

CHANGELOG.md

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
1-
# 3.0.0-beta3 (unreleased)
2-
3-
### Bug fixes
4-
* **Postgres**: Fixed page render crash when using postgres, fixes [#4558](https://github.com/grafana/grafana/issues/4558)
5-
* **Table panel**: Fixed table panel bug when trying to show annotations in table panel, fixes [#4563](https://github.com/grafana/grafana/issues/4563)
6-
* **App Config**: Fixed app config issue showing content of other app config, fixes [#4575](https://github.com/grafana/grafana/issues/4575)
7-
* **Graph Panel**: Fixed legend option max not updating, fixes [#4601](https://github.com/grafana/grafana/issues/4601)
8-
* **Graph Panel**: Fixed issue where newly added graph panels shared same axes config, fixes [#4582](https://github.com/grafana/grafana/issues/4582)
9-
10-
# 3.0.0-beta2 (2016-04-04)
1+
# 3.0.0-beta2 (unreleased)
112

123
### New Features (introduces since 3.0-beta1)
134
* **Preferences**: Set home dashboard on user and org level, closes [#1678](https://github.com/grafana/grafana/issues/1678)
@@ -18,9 +9,8 @@
189
* **Dashboard**: Fixed dashboard panel layout for mobile devices, fixes [#4529](https://github.com/grafana/grafana/issues/4529)
1910
* **Table Panel**: Fixed issue with table panel sort, fixes [#4532](https://github.com/grafana/grafana/issues/4532)
2011
* **Page Load Crash**: A Datasource with null jsonData would make Grafana fail to load page, fixes [#4536](https://github.com/grafana/grafana/issues/4536)
21-
* **Metrics tab**: Fix for missing datasource name in datasource selector, fixes [#4540](https://github.com/grafana/grafana/issues/4540)
12+
* **Metrics tab**: Fix for missing datasource name in datasource selector, fixes [#4541](https://github.com/grafana/grafana/issues/4540)
2213
* **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)
23-
* **Password**: Password reset link/page did not work, fixes [#4542](https://github.com/grafana/grafana/issues/4542)
2414

2515
# 3.0.0-beta1 (2016-03-31)
2616

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
},
6868
"license": "Apache-2.0",
6969
"dependencies": {
70+
"eventemitter3": "^1.2.0",
7071
"grunt-jscs": "~1.5.x",
7172
"grunt-sass-lint": "^0.1.0",
7273
"grunt-sync": "^0.4.1",

public/app/core/utils/emitter.ts

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
///<reference path="../../headers/common.d.ts" />
22

3-
import {Subject} from 'vendor/npm/rxjs/Subject';
3+
import EventEmitter from 'eventemitter3';
44

55
var hasOwnProp = {}.hasOwnProperty;
66

@@ -9,48 +9,27 @@ function createName(name) {
99
}
1010

1111
export class Emitter {
12-
subjects: any;
12+
emitter: any;
1313

1414
constructor() {
15-
this.subjects = {};
15+
this.emitter = new EventEmitter();
1616
}
1717

1818
emit(name, data?) {
19-
var fnName = createName(name);
20-
this.subjects[fnName] || (this.subjects[fnName] = new Subject());
21-
this.subjects[fnName].next(data);
19+
this.emitter.emit(name, data);
2220
}
2321

2422
on(name, handler, scope?) {
25-
var fnName = createName(name);
26-
this.subjects[fnName] || (this.subjects[fnName] = new Subject());
27-
var subscription = this.subjects[fnName].subscribe(handler);
23+
this.emitter.on(name, handler);
2824

2925
if (scope) {
3026
scope.$on('$destroy', function() {
31-
subscription.unsubscribe();
27+
this.emitter.off(name, handler);
3228
});
3329
}
34-
35-
return subscription;
36-
};
37-
38-
off(name, handler) {
39-
var fnName = createName(name);
40-
if (this.subjects[fnName]) {
41-
this.subjects[fnName].dispose();
42-
delete this.subjects[fnName];
43-
}
4430
}
4531

46-
dispose() {
47-
var subjects = this.subjects;
48-
for (var prop in subjects) {
49-
if (hasOwnProp.call(subjects, prop)) {
50-
subjects[prop].dispose();
51-
}
52-
}
53-
54-
this.subjects = {};
32+
off(name, handler) {
33+
this.emitter.off(name, handler);
5534
}
5635
}

public/app/headers/common.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,8 @@ declare module 'tether-drop' {
4747
var config: any;
4848
export default config;
4949
}
50+
51+
declare module 'eventemitter3' {
52+
var config: any;
53+
export default config;
54+
}

public/app/system.conf.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ System.config({
44
paths: {
55
'remarkable': 'vendor/npm/remarkable/dist/remarkable.js',
66
'tether': 'vendor/npm/tether/dist/js/tether.js',
7+
'eventemitter3': 'vendor/npm/eventemitter3/index.js',
78
'tether-drop': 'vendor/npm/tether-drop/dist/js/drop.js',
89
'moment': 'vendor/moment.js',
910
"jquery": "vendor/jquery/dist/jquery.js",
@@ -55,5 +56,9 @@ System.config({
5556
deps: ['jquery'],
5657
exports: 'angular',
5758
},
59+
'vendor/npm/eventemitter3/index.js': {
60+
format: 'cjs',
61+
exports: 'EventEmitter'
62+
},
5863
}
5964
});

public/sass/utils/_utils.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ button.close {
5252
.pull-right {
5353
float: right !important;
5454
}
55+
5556
.pull-left {
5657
float: left !important;
5758
}

public/test/core/utils/emitter_specs.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ describe("Emitter", () => {
2424
expect(sub2Called).to.be(true);
2525
});
2626

27-
it('should handle errors', () => {
27+
it.only('should handle errors', () => {
2828
var events = new Emitter();
2929
var sub1Called = 0;
3030
var sub2Called = 0;
3131

32-
var sub1 = events.on('test', () => {
32+
events.on('test', () => {
3333
sub1Called++;
3434
throw "hello";
3535
});
@@ -41,8 +41,8 @@ describe("Emitter", () => {
4141
try { events.emit('test', null); } catch (_) { }
4242
try { events.emit('test', null); } catch (_) {}
4343

44-
expect(sub1Called).to.be(1);
45-
expect(sub2Called).to.be(1);
44+
expect(sub1Called).to.be(2);
45+
expect(sub2Called).to.be(0);
4646
});
4747
});
4848
});

public/test/test-main.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
baseURL: '/base/',
1111
defaultJSExtensions: true,
1212
paths: {
13+
'eventemitter3': 'vendor/npm/eventemitter3/index.js',
1314
'tether': 'vendor/npm/tether/dist/js/tether.js',
1415
'tether-drop': 'vendor/npm/tether-drop/dist/js/drop.js',
1516
'moment': 'vendor/moment.js',
@@ -58,7 +59,11 @@
5859
'vendor/angular-mocks/angular-mocks.js': {
5960
format: 'global',
6061
deps: ['angular'],
61-
}
62+
},
63+
'vendor/npm/eventemitter3/index.js': {
64+
format: 'cjs',
65+
exports: 'EventEmitter'
66+
},
6267
}
6368
});
6469

tasks/options/copy.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ module.exports = function(config) {
1919
cwd: './node_modules',
2020
expand: true,
2121
src: [
22-
'angular2/bundles/*.js',
23-
'angular2/*.d.ts',
24-
'angular2/typings/**/*',
25-
'angular2/manual_typings/**/*',
22+
'eventemitter3/*.js',
2623
'systemjs/dist/*.js',
2724
'es6-promise/**/*',
2825
'es6-shim/*.js',

0 commit comments

Comments
 (0)