Moving IEmitter
This commit is contained in:
parent
8ba7fd628c
commit
79ff27cec2
@ -16,6 +16,7 @@ import {
|
|||||||
IAvailableServicesMsg,
|
IAvailableServicesMsg,
|
||||||
IAvailableTopicsMsg,
|
IAvailableTopicsMsg,
|
||||||
ICommunicationInterface,
|
ICommunicationInterface,
|
||||||
|
IEmitter,
|
||||||
IExternalEventMsg,
|
IExternalEventMsg,
|
||||||
IRequestTaskMsg,
|
IRequestTaskMsg,
|
||||||
IResponseTaskMsg,
|
IResponseTaskMsg,
|
||||||
@ -24,14 +25,6 @@ import {
|
|||||||
import { IDispatcherInfo } from "../types/nope/nopeDispatcher.interface";
|
import { IDispatcherInfo } from "../types/nope/nopeDispatcher.interface";
|
||||||
import { INopeObservable } from "../types/nope/nopeObservable.interface";
|
import { INopeObservable } from "../types/nope/nopeObservable.interface";
|
||||||
|
|
||||||
export interface IEmitter {
|
|
||||||
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
||||||
off(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
||||||
emit(event: string | symbol, ...args: any[]): boolean;
|
|
||||||
getMaxListeners?: () => number;
|
|
||||||
setMaxListeners?: (n: number) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Communication Layer for the Dispatchers.
|
* A Communication Layer for the Dispatchers.
|
||||||
* Here, only a Events are used.
|
* Here, only a Events are used.
|
||||||
@ -43,7 +36,7 @@ export interface IEmitter {
|
|||||||
export class EventLayer implements ICommunicationInterface {
|
export class EventLayer implements ICommunicationInterface {
|
||||||
connected: INopeObservable<boolean>;
|
connected: INopeObservable<boolean>;
|
||||||
considerConnection = true;
|
considerConnection = true;
|
||||||
allowServiceRedundancy = false
|
allowServiceRedundancy = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creaetes an Event Emitter-based Communication Layer:
|
* Creaetes an Event Emitter-based Communication Layer:
|
||||||
@ -58,7 +51,7 @@ export class EventLayer implements ICommunicationInterface {
|
|||||||
this.connected.setContent(true);
|
this.connected.setContent(true);
|
||||||
this.id = generateId();
|
this.id = generateId();
|
||||||
}
|
}
|
||||||
|
|
||||||
id: string;
|
id: string;
|
||||||
|
|
||||||
protected _on(event: string, cb) {
|
protected _on(event: string, cb) {
|
||||||
@ -204,7 +197,7 @@ export class EventLayer implements ICommunicationInterface {
|
|||||||
this._emitter.off("event_" + event, cb);
|
this._emitter.off("event_" + event, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
async dispose(){
|
async dispose(): Promise<void> {
|
||||||
this.connected.dispose();
|
this.connected.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user