Commit 3ea441d1 by Torkel Ödegaard

feat(live): tricky

parent e63ff1c7
......@@ -4,6 +4,21 @@ import {liveSrv} from 'app/core/core';
import {Observable} from 'vendor/npm/rxjs/Observable';
class DataObservable {
target: any;
constructor(target) {
this.target = target;
}
subscribe(options) {
var observable = liveSrv.subscribe(this.target.stream);
return observable.subscribe(data => {
console.log("grafana stream ds data!", data);
});
}
}
export class GrafanaStreamDS {
subscription: any;
......@@ -12,30 +27,15 @@ export class GrafanaStreamDS {
}
query(options) {
query(options): any {
if (options.targets.length === 0) {
return Promise.resolve({data: []});
}
var target = options.targets[0];
var observable = new DataObservable(target);
if (this.subscription) {
if (this.subscription.stream !== target.stream) {
this.subscription.unsubscribe();
} else {
return Promise.resolve({data: []});
}
}
var observable = liveSrv.subscribe(target.stream);
this.subscription = observable.subscribe(data => {
console.log("grafana stream ds data!", data);
});
this.subscription.stream = target.stream;
return Promise.resolve({data: []});
return Promise.resolve(observable);
}
}
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