KangoExtensions / kango

Kango framework issue tracker
74 stars 7 forks source link

node-style invocation of callbacks #117

Open iamolivinius opened 9 years ago

iamolivinius commented 9 years ago

I'm using kango a lot in my work and included https://github.com/mozilla/localForage lately to have the ability of an unlimted storage. Cause localForage handles callbacks in a "node-ish" (link) way its no longer compatible with kango.

One can argue that this pattern of callback invocation is becoming more and more popular within the javascript ecosystem, especially with node modules and browserify, that many users would benefit if kango would change its api to be compliant with that style.

I'm aware of the fact that this is a breaking change for the current kango API but maybe it's something you can agree on.

Old:

kango.invokeAsyncCallback('localforage.getItem', 'key', function (data) {
  console.log(data);
});

New:

kango.invokeAsyncCallback('localforage.getItem', 'key', function (err, data) {
  console.log(data);
});
iamolivinius commented 9 years ago

This is still a matter of interest for me and I'd love to get some feedback on this, please.

I did some debugging of the kango/invoke_async module today and found out that the "intermediate" callback only handles one argument. So as for today I'd rephrase my request to be more general:

Can you improve the invokeAsyncCallback method in a way that we can write callback functions with multiple arguments?