Skip to content

Commit

Permalink
fix: refactor request manager connect
Browse files Browse the repository at this point in the history
  • Loading branch information
BelfordZ committed Jul 26, 2019
1 parent 8bcf352 commit ea19ecf
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/RequestManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,10 @@ class RequestManager {
}

public connect(): Promise<any> {
const promises = this.transports.map((transport) => {
return new Promise(async (resolve, reject) => {
await transport.connect();
transport.onData((data: any) => {
this.onData(data);
});
resolve();
});
});
return Promise.all(promises);
return Promise.all(this.transports.map(async (transport) => {
await transport.connect();
transport.onData(this.onData.bind(this));
}));
}

public async request(method: string, params: any): Promise<any> {
Expand Down

0 comments on commit ea19ecf

Please sign in to comment.