node-xmlrpc icon indicating copy to clipboard operation
node-xmlrpc copied to clipboard

Support for ES6 Proxy style client calls

Open zdychacek opened this issue 10 years ago • 3 comments

Hi,

this pull request extends the client with an ability of making calls using ES6 Proxy API.

It extends Client class with $ property which is an instance of the Proxy object. This object allows you to call methods directly in following style:

var promise = client.$.company.employees.getDetail(1, true);
// -> calls registered method on server (company.employees.getDetail) and returns Promise

This pull request also adds a new method Client#methodCallPromise() which is a Promise based wrapper around the Client#methodCall() method.

You can find an example of this feature in example/proxy_calls.js file and in Readme as well.

If you like this feature, you can merge it :)

zdychacek avatar May 01 '15 17:05 zdychacek

Oh yes. It won't work with older versions of node. Therefore failed build for node v0.8...

zdychacek avatar May 01 '15 19:05 zdychacek

Hi @zdychacek

Thank you for your work, I like the promise API you propose but we also need to retain the callback functionality (I'd keep that default) and I'd prefer to be compatible with 0.8.x as long as possible.

I'd also like to get some more opinions on this :)

In the meantime, could you please edit README.md to describe the proxy as a separate feature, for example how "cookies" has been described.

patricklodder avatar May 02 '15 11:05 patricklodder

Hi @patricklodder,

it's not a problem to retain callback style along with the proxy feature. Going to rewrite that.

I will describe the usage of proxy feature in README.md as a separate feature then.

zdychacek avatar May 05 '15 19:05 zdychacek