Most of the methods are designed to work asynchronously.
Please, provide a consistent pattern to handle asynchronous stuff.
Would be nice to avoid the need to pass a double callback (one for success, one for error) each time.
A single callback is enough, first argument should be an intanceof Error, if falsy (null, undefined, w/e), then assumed to be a success case.
Would be nice to always define the callback as the last parameter, no additional arguments after one (or two for some cases in current API) potentially very long callback. Difficult to see the whole list of arguments.
Kind.prototype.fetch = function(bob, foo, ..., callback) {
// do stuff ...
Gh3.Helper.callHttpApi({
service : url,
success : function(res) {
callback(null, res);
},
error : function (res) {
callbac(new Error(res));
}
});
};
...
var bob = new Kind;
bob.fetch(function('bob', 'and', 'his', 'friends', function(err, response) {
console.log('fetching bob and is friends');
if(err) {
// deal with error
return;
}
// handle response
console.log(response);
});
:)
yes, it will be provided, Atinux has already made the remark, you're all right.
thank you for sample.
i'm going to do that. I will probably submit you code snippet before commit.
Most of the methods are designed to work asynchronously.