3 ms·
This is actually very cool. I've never heard of Promises/A before, but after toying with Node.JS a bit (and being turned off after having many nested callbacks
by matthuggins 14y ago
This is actually very cool. I've never heard of Promises/A before, but after toying with Node.JS a bit (and being turned off after having many nested callbacks in my code), I am definitely a fan of the flat code structure this library allows.
Although it's obviously not built in favor of any particular JS framework or environment, it may entice me to give Node.JS another shot in the future with implementing RSVP.
- pfraze 14y agoI've been using promises for my work lately, and I really like them. This doesn't have it, but one construct I use is the `when` function. It's useful for situations that may return non-promise values, and works like this: Promise.when(func(), function(val) { alert(val); }); So if `func` returns a normal value, the cb runs immediately. If it returns a promise, the cb runs on fulfillment.
- lancefisher 14y agoNested callbacks are a problem that every javascript/node.js developer runs in to. A common library to help with this and other issues is Async: https://github.com/caolan/async https://github.com/caolan/async Sometimes, it's just better to give your functions names, and pull them out. RSVP.js looks nice. Also, I like jQuery's implantation of promises specifically with the ajax function.