Yeah promises are great because they map perfectly with the asynchronous 
nature of the browser platform. Netflix has been very successfully using 
promises on the server side as well. Almost all of their server-side 
services are promise-based which has proved invaluable to adapting to 
scalability  requirements without breaking consumers of their APIs. Here's 
a relavent excerpt from  this blog post  
http://techblog.netflix.com/2013/02/rxjava-netflix-api.html.  Although 
rxJava is more than just promises, I think what this says perfectly applies 
to promise-based api design in angular (just replace Observable<T> with 
Promise):

Observable Service Layer

The Netflix API takes advantage of Rx by making the entire service layer 
asynchronous (or at least appear so) - all "service" methods return an 
Observable<T>.

Making all return types Observable combined with a functional programming 
model frees up the service layer implementation to safely use concurrency. 
It also enables the service layer implementation to:


   - conditionally return immediately from a cache
      - block instead of using threads if resources are constrained
      - use multiple threads
      - use non-blocking IO
      - migrate an underlying implementation from network based to 
      in-memory cache
   
This can all happen without ever changing how client code interacts with or 
composes responses.

In short, client code treats all interactions with the API as asynchronous 
but the implementation chooses if something is blocking or non-blocking.

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to