2016-09-22 10:00:33 +00:00
|
|
|
"use strict";
|
2017-04-09 14:29:14 +00:00
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
2016-09-22 10:00:33 +00:00
|
|
|
const plugins = require("./lik.plugins");
|
|
|
|
const lik_objectmap_1 = require("./lik.objectmap");
|
2016-11-19 22:08:54 +00:00
|
|
|
/**
|
|
|
|
* manages observables by making sure that only one observable is regsitered per event
|
|
|
|
*/
|
2016-09-22 10:00:33 +00:00
|
|
|
class Observablemap {
|
|
|
|
constructor() {
|
|
|
|
this.ObservableEmitterBundleObjectmap = new lik_objectmap_1.Objectmap();
|
|
|
|
}
|
2016-11-19 22:08:54 +00:00
|
|
|
/**
|
|
|
|
* creates a new observable if not yet registered for the same event.
|
|
|
|
* In case event has been registered before the same observable is returned.
|
|
|
|
*/
|
2016-09-22 10:00:33 +00:00
|
|
|
getObservableForEmitterEvent(emitterArg, eventArg) {
|
|
|
|
let existingBundle = this.ObservableEmitterBundleObjectmap.find((bundleArg) => {
|
|
|
|
return (bundleArg.emitter === emitterArg && bundleArg.event === eventArg);
|
|
|
|
});
|
|
|
|
if (existingBundle) {
|
|
|
|
return existingBundle.observable;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
let emitterObservable = plugins.rx.Observable.fromEvent(emitterArg, eventArg);
|
|
|
|
this.ObservableEmitterBundleObjectmap.add({
|
|
|
|
observable: emitterObservable,
|
|
|
|
emitter: emitterArg,
|
|
|
|
event: eventArg
|
|
|
|
});
|
|
|
|
return emitterObservable;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exports.Observablemap = Observablemap;
|
2017-04-09 14:29:14 +00:00
|
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGlrLm9ic2VydmFibGVtYXAuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9saWsub2JzZXJ2YWJsZW1hcC50cyJdLCJuYW1lcyI6W10sIm1hcHBp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