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

Move most of APIClient interface to its promise chain #6022

Merged
merged 1 commit into from
May 19, 2020

Conversation

nb-ohad
Copy link
Contributor

@nb-ohad nb-ohad commented May 17, 2020

Explain the changes

This change will decrease the size of an APiClient object to an object with a single field named options.
The interface objects (which contain the method declaration) will be generated on the fly on each access and will consist of a single field named client that point back to the client that created them.
The methods themselves are not implemented on the prototype of each API object.

A side effect of this change is that we cannot pass an API method directly as a callback because it loses its context. A workaround is to pass an arrow function that preserves the context as I did for node.n2n_signal

This PR is an alternative to the solution presented in PR #6017

src/api/api.js Show resolved Hide resolved
src/api/api.js Outdated Show resolved Hide resolved
src/api/api.js Outdated Show resolved Hide resolved
src/api/api.js Outdated Show resolved Hide resolved
src/api/api.js Outdated Show resolved Hide resolved
src/agent/agent.js Outdated Show resolved Hide resolved
src/api/api.js Show resolved Hide resolved
@nb-ohad nb-ohad force-pushed the ohad-leaner-api-client branch 2 times, most recently from 3ee014c to b8aee35 Compare May 19, 2020 09:51
@guymguym
Copy link
Member

@nb-ohad Can you squash your commits?

This change will decrease the size of an APiClient object to an object with a 2 fields an rpc reference and the options for the client.
The interface objects (which contain the method declaration) will be generated on the fly on each access and will consist of a single field named `client` that point back to the client that created them.
The methods themselves are now implemented on the prototype of each API object.

A side effect of this change is that we cannot pass an API method directly as a callback because it loses its context. A workaround is to pass an arrow function that preserves the context. See the changes to node.n2n_singal as an example.
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.

2 participants