UWNetworksLab / freedom

Embracing a distributed web
13 stars 5 forks source link

Migrate core providers to promiseProvider interface #56

Open iislucas opened 10 years ago

iislucas commented 10 years ago

This allows nicer handling of errors.

willscott commented 10 years ago

promiseProvider isn't technically needed :smile: The asynchronousProvider passes an errback argument as well as the continuation / callback, which can be done to add rejection without converting a full provider. We can also make the synchronousProvider catch thrown errors and use those as rejections.

iislucas commented 10 years ago

Or equivalently, asynchronousProvider isn't technically needed, right? :)

I actually didn't realize there that there was an error propagation mechanism before; that's cool.

willscott commented 10 years ago

error propagation got put in at the same time as promises to keep interfaces functionally equivalent. I don't know if I feel like I want to force every provider to use promises. I can imagine providers using preexisting code, and I'd like to make it as easy as possible for 3rd party code to become a freedom.js provider.

iislucas commented 10 years ago

Sure; same argument with Promises. Not actually proposing removing any interface here :)

Just suggesting that core providers use promises (I think that's better coding style to promise) and more importantly, that they signal errors back where appropriate. e.g. as per discussion on social API failure to login, etc.