Skip to content

Conversation

Vitaliy136
Copy link

No description provided.

justmoon and others added 27 commits July 1, 2011 22:19
Callbacks should always take an "err" argument first for asynchronous
error handling.

Callbacks should be passed in as the last parameter (this was already
the case).

The parameter array should be passed in as an array. -- Now, I had
quite some internal debate about this. It is nicer syntax-wise to have
the arguments come in as actual arguments, not as an array.

However, it does have the effect that the callback parameter moves
around depending on user-submitted data. So the function will have to
handle finding out which parameter is the callback, which is a lot
uglier and more error-prone than just passing in the arguments as an
array.

Finally, I've added an additional parameter "opt" which contains the
HTTP request object and the server object. This is useful as an
extensible way to deliver more features and options to the handler in
future versions of the library.

Here is an example handler with the new syntax:

server.expose('multiply', function (args, opt, callback) {
  var a = args[0],
      b = args[1];

  callback(null, a*b);
});
Handle and report errors from the http client.
Hi! I fixed some calls to "sys" for you!
@jb55
Copy link
Owner

jb55 commented Aug 2, 2013

did you mean to make a PR to jsonrpc2? This is an old version of jsonrpc.

@Vitaliy136
Copy link
Author

Optional enable log(trace)
no, i mean disable logs if don't need it (i have other console log output)

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.

6 participants