3 ms·
That last line return Mustache.render(template, data) Isn't exactly equivalent to the non-promise one, since now `Mustache.render` is async, is it?
by ricardobeat 15y ago
That last line
return Mustache.render(template, data)
Isn't exactly equivalent to the non-promise one, since now `Mustache.render` is async, is it?
- wonnage 15y agoIt's much more useful now, IMO. Now you can chain an error handler onto your view's render method, and the level of abstraction becomes "I couldn't render the view" rather than "I couldn't get some JSON from the server". Functionally the behavior is the same - you're still going to have to gate an asynchronous stream of actions (make sure steps a, b, c have completed before d, etc.), but with this, you can describe that logic where it matters - renderView().then(attachHandlers).then..., instead of callback nesting hell (attachHandlers would have to be in renderView).
- gozala 15y agoYeah I had this comment there // Assuming Mustache.render = promised(Mustache.render) But my hope is that more libraries will be accepting promises in a future so one won't have to do the wrapping of a world around.