Skip to content

Commit

Permalink
fix: remove null checks on Event Emitter
Browse files Browse the repository at this point in the history
  • Loading branch information
shanejonas committed May 14, 2019
1 parent 5cfad43 commit d677e0b
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions src/transports/EventEmitterTransport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,23 @@ import { EventEmitter } from "events";
import ITransport from "./Transport";

class EventEmitterTransport implements ITransport {
public connection: EventEmitter | null;
public connection: EventEmitter;
constructor(uri: string) {
this.connection = new EventEmitter();
}
public connect(): Promise<any> {
// noop
return Promise.resolve();
}
public onData(callback: any) {
if (!this.connection) {
return;
}
this.connection.addListener("message", (data: any) => {
callback(data);
});
}
public sendData(data: any) {
if (!this.connection) {
return;
}
this.connection.emit("message", data);
}
public close() {
if (!this.connection) {
return;
}
this.connection.removeAllListeners();
this.connection = null;
}
}

Expand Down

0 comments on commit d677e0b

Please sign in to comment.