2016-09-22 10:00:33 +00:00
|
|
|
"use strict";
|
|
|
|
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;
|
2016-11-19 22:08:54 +00:00
|
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGlrLm9ic2VydmFibGVtYXAuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9saWsub2JzZXJ2YWJsZW1hcC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEseUNBQXdDO0FBQ3hDLG1EQUEyQztBQWMzQzs7R0FFRztBQUNIO0lBQU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