how to pass multiple results to client side
Closed this issue · 1 comments
enginespot commented
sometimes we want to get multiple arguments from server side , for example, we want server side put arg1, arg2, arg3 to client side, I know we can use JSON ,like
callback(null,{arg1:"arg1",arg2:"arg2",arg3:"arg3"}) [server side]
but sometimes we want write it as:
callback(null,'arg1','arg2','arg3') [server side]
so how to do it?
client.invoke("method",'1', function(error, arg1,arg2,arg3, more) {
if (error) {
console.error(error);
} else {
console.log("UPDATE:", arg1,arg2,arg3);
}
if (!more) {
console.log("Done.");
}
});
shin- commented
Hi!
There's no plan to support it at the moment, especially because healthier alternatives exist, such as
callback(err, [arg1, arg2, arg3]);
The idea is to stick as close as possible to what you would expect from any other Node.js library, where callbacks are formatted this way. (i.e. callback(error, result)
).