Skip to content

Conversation

@AlbyIanna
Copy link
Contributor

No description provided.

@AlbyIanna AlbyIanna requested a review from destegabry June 27, 2018 14:47
jsonMessage = JSON.parse(message);
}
catch (SyntaxError) {
return;
Copy link
Contributor

@destegabry destegabry Jul 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth emitting a parse error for log/debug/error-displaying purpose?

export const AGENT_STATUS_CONNECTED = 'AGENT_CONNECTED';
export const AGENT_STATUS_DISCONNECTED = 'AGENT_DISCONNECTED';
export const AGENT_STATUS_FOUND = 'AGENT_FOUND';
export const AGENT_STATUS_NOT_FOUND = 'AGENT_NOT_FOUND';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Way better naming!


this.readerWriter = new ReaderWriter();
this.wsConnectionStatus.subscribe(status => {
if (status === WS_STATUS_CONNECTED) {
Copy link
Contributor

@destegabry destegabry Jul 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to replace the if with the RxJS filter operator like:

this.wsConnectionStatus
  .filter(status => status === WS_STATUS_CONNECTED)
  .subscribe(status => {
     this.readerWriter.initSocket(this.socket)
  });

"detect-browser": "^2.5.1",
"rxjs": "^6.2.1",
"semver-compare": "^1.0.0",
"socket.io-client": "1.7.4"
Copy link
Contributor

@destegabry destegabry Jul 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check if it's worth to move from "native" socket.io-client to https://www.npmjs.com/package/rxjs-socket.io

Copy link
Contributor

@destegabry destegabry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested the web app locally (but I have not any device to test listing), seems working to me, I just added some comments to improve the usage of rxjs

data = JSON.parse(message);
}
catch (SyntaxError) {
return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth emitting a parse error for log/debug/error-displaying purpose?

})
.finally(() => {
if (!this.isConnected()) {
setTimeout(find, 3000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move to rxjs interval, using observables to launch it:

  • when agent is disconnected socket polling should be disabled and agent polling should be started
  • when agent is connected socket polling should be started and agent polling should be disabled

@smellai smellai merged commit 2e82937 into master Jul 10, 2018
@smellai smellai deleted the refactoring-rxjs branch July 10, 2018 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants