fix(core): update
This commit is contained in:
parent
c4d48b17e9
commit
9908d759c6
@ -1,12 +1,15 @@
|
|||||||
import * as plugins from './smartrx.plugins';
|
import * as plugins from './smartrx.plugins';
|
||||||
import { EventEmitter } from '@pushrocks/smartevent';
|
|
||||||
|
export interface IEventEmitter<T = any> {
|
||||||
|
on: (eventNameArg: string, eventHandlerArg: ((eventPayload: T) => any)) => void;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* bundles an observable with an emitter
|
* bundles an observable with an emitter
|
||||||
*/
|
*/
|
||||||
export interface IObservableEmitterBundle {
|
export interface IObservableEmitterBundle {
|
||||||
observable: plugins.rxjs.Observable<any>;
|
observable: plugins.rxjs.Observable<any>;
|
||||||
emitter: EventEmitter;
|
emitter: IEventEmitter<unknown>;
|
||||||
event: string;
|
event: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -20,14 +23,14 @@ export class Observablemap {
|
|||||||
* creates a new observable if not yet registered for the same event.
|
* creates a new observable if not yet registered for the same event.
|
||||||
* In case event has been registered before the same observable is returned.
|
* In case event has been registered before the same observable is returned.
|
||||||
*/
|
*/
|
||||||
public getObservableForEmitterEvent(emitterArg: EventEmitter, eventArg: string) {
|
public getObservableForEmitterEvent<T>(emitterArg: IEventEmitter<T>, eventArg: string) {
|
||||||
const existingBundle = this.observableEmitterBundleObjectmap.find(bundleArg => {
|
const existingBundle = this.observableEmitterBundleObjectmap.find(bundleArg => {
|
||||||
return bundleArg.emitter === emitterArg && bundleArg.event === eventArg;
|
return bundleArg.emitter === emitterArg && bundleArg.event === eventArg;
|
||||||
});
|
});
|
||||||
if (existingBundle) {
|
if (existingBundle) {
|
||||||
return existingBundle.observable;
|
return existingBundle.observable;
|
||||||
} else {
|
} else {
|
||||||
const emitterObservable = plugins.rxjs.fromEvent(emitterArg, eventArg);
|
const emitterObservable = plugins.rxjs.fromEvent<T>(emitterArg as any, eventArg);
|
||||||
this.observableEmitterBundleObjectmap.add({
|
this.observableEmitterBundleObjectmap.add({
|
||||||
observable: emitterObservable,
|
observable: emitterObservable,
|
||||||
emitter: emitterArg,
|
emitter: emitterArg,
|
||||||
|
Loading…
Reference in New Issue
Block a user