Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: refactor remoteProxy using classes #269

Closed
wants to merge 1 commit into from

Conversation

nechaido
Copy link
Member

No description provided.

@nechaido nechaido added the lib label Jul 25, 2017
@@ -1,69 +1,64 @@
'use strict';

const events = require('events');
const util = require('util');
const EventEmitter = require('events').EventEmitter;
Copy link
Member

Choose a reason for hiding this comment

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

You should use destructuring assignment here to keep the style consistent.


// Create a method in a remote proxy that will call the corresponding remote
// method. This is implemented as a static method rather than an instance
Copy link
Member

Choose a reason for hiding this comment

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

This is implemented as a static method rather than an instance method so that it will not be rewritten by a remote API method with the same name.

Why did you change it?
I think that reasoning here is clear and it should still be a static method after refactoring.

Copy link
Member Author

Choose a reason for hiding this comment

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

@belochub it is only called in the constructor, so even it is going to be rewritten nothing bad will happen, also it is very unlikely for a public api to have method to start with an underscore.
@aqrln what do you think about this?

Copy link
Member Author

Choose a reason for hiding this comment

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

@aqrln ping.

Copy link
Member

@aqrln aqrln Jul 26, 2017

Choose a reason for hiding this comment

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

It is okay to make it an instance method. Nothing bad will actually happen even if it gets overwritten. The possibility of having emit and on methods in an interface is much more concerning.

UPD: actually it can be overwritten before other methods are wrapped in the constructor. It can be mitigated via const wrap = this._wrapRemoteMethod.bind(this); and calling the wrap function inside the loop though, or even moving the function out of the class and making it taking a proxy instance as its argument.

@nechaido nechaido removed the request for review from aqrln September 26, 2017 10:51
nechaido added a commit that referenced this pull request Sep 26, 2017
PR-URL: #269
Reviewed-By: Mykola Bilochub <nbelochub@gmail.com>
@nechaido
Copy link
Member Author

Landed in de38e27.

@nechaido nechaido closed this Sep 26, 2017
@nechaido nechaido deleted the refactoring/remote-proxy branch September 26, 2017 11:58
belochub pushed a commit that referenced this pull request Jan 22, 2018
PR-URL: #269
Reviewed-By: Mykola Bilochub <nbelochub@gmail.com>
belochub pushed a commit that referenced this pull request Jan 22, 2018
PR-URL: #269
Reviewed-By: Mykola Bilochub <nbelochub@gmail.com>
@belochub belochub mentioned this pull request Jan 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants