jrpc2-proxy
v0.2.1
Published
Auto-generate client-side proxy objects and functions for jrpc2
Downloads
10
Readme
jrpc2-proxy
Auto-generate client-side proxy objects and functions for jrpc2
Examples
Services
var rpc = require('jrpc2');
var proxy = require("jrpc2-proxy");
var AjaxTransport = require("jrpc2-ajax");
var transport = new AjaxTransport({path: "/api/"});
var client = new rpc.Client(transport);
var userService = proxy.createService(client, ["fetchUsers", "getUser"]);
userService.fetchUsers()
.then(...);
userService.fetchUsers(function(err, users) {
...
});
userService.getUser(id)
.then(...)
userService.getUser(id, function(err, user) {
...
})
Functions
var loadPosts = proxy.createFunction(client, "loadPosts");
loadPosts(queryParams).then(...etc);
TODO
- Support ES6 proxies
- Create proxy from remote schema