javascript - Is there a cleaner way to chain these Bluebird promises? -


i have 3 functions (a, b, c) each return promise. chain of promises don't require information previous promises except complete.

b has wait finish, , c has wait b finish.

currently have:

return a(thing) .then(function () {   return b(anotherthing); }) .then(function () {   return c(somethingelse); }); 

this feels i'm wasting lot of space (7 lines 3 lines of actual code).

this works

return a(thing)     .then(b.bind(null,anotherthing))     .then(c.bind(null,somethingelse)); 

note: bind not available on ie8 or earlier - there's polyfill - https://developer.mozilla.org/en-us/docs/web/javascript/reference/global_objects/function/bind

for info - in es2015 - iojs let enable arrow functions, apparently broken in way

return a(thing)     .then(() => b(anotherthing))     .then(() => c(somethingelse)); 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -