Hacker News new | ask | show | jobs
by timruffles 4233 days ago
Nice looking app!

You're not doing promises right however :) `$http.get()` etc returns a promise, so you can do all transforms and logic via `.then()`. The only time you should ever use `$q.defer()` is when you're wrapping a non-promise API. The bluebird library has a nice write-up: https://github.com/petkaantonov/bluebird/wiki/Promise-anti-p...

2 comments

Promises are pretty great, too. I wrote some (now in production!) feature detection/facial recognition code using OpenCV through the node-opencv library, but as some of the big calls were async and I needed it to work in a somewhat synchronous way, I wrapped it all up in Q. Once you understand how they work, they can be quite great.
This is a really common mistake I have found with angular shops - almost none realize that all $http is is an augmented $q.when promise.