It depends a lot on the app and the users and their network. I originally went the other way - lots and lots of little $http.get requests generated by my application. I cached stuff so I only had to load any given thing once per lifecycle, but if you hit the "everybody's conversations" page, it generated about 100-200 separate XHR requests.
What I found was that this would go very slowly in high-latency networks. When it costs ~1000 ms to roundtrip the server just because my user is at a school in a network with many ill-configured firewalls and proxies, or at a hotel on a very busy network, this went really slowly because the browser could only open so many connections at once before waiting on one of them to close. So instead, I implemented a post batcher that would collect 50 ms worth of requests and send them all at once to the backend (I'm using hapiJS for node, and there's a straightforward batch processor plugin called bassmaster for it). Hey presto - better performance in slow networks. Of course, it is also unsatisfying to a fast user to see the delay - 50 ms isn't too long, but then the batch request (naturally) takes longer to run than any individual request, so fast-network users see a more noticeable delay. I'm still working on tweaking it. The nice thing is, because I ended up creating a new service that wraps $http, I can make all kinds of changes and they're all in only one place. Eric On Thu, Sep 18, 2014 at 8:02 AM, Dan Rybij <[email protected]> wrote: > I'm a bit of old school - I always try to minimize anything that appears > 'expensive' and in computer terms, that means avoiding too many operations > where I would be waiting for responses from a remote system. > > So when I started with using angular, I started a pattern of packaging up > multiple requests for data into a single array, POSTing that and in my > back-end script I fulfill each request, package up the results and send > whole the package back at once. This works great. When my script loads it > only sends one POST and expects only one response. I'm not directly using > promises. > > But I suspect this is an anti-pattern as far as angular is concerned. I'm > probably running design limitations. > > So, if I lose the packaging mechanism and simply request the data items > individually as I need them, cache data appropriately in a model, and start > to use promises can you tell me if this is how the app is supposed to be > designed? Is this how you do it? > > -- > 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/d/optout. > -- 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/d/optout.
