rest - Aggregated Data vs RESTful Resources for AngularJs SPA -
i working on single page app using angularjs framework.
website kind of social networking , consists of various kinds of data fetched server.
restful , make each entity 'resource' or implement other way 'aggregated json' response, since restful results in many calls ?
if non-restful approach used, ( using $http
service ), how can still maintain modular architecture of app.
consider example clarification:
let server return:
{ user: { name: .... ...., projects: [{ .... .... }], ... } }
how can create modules such user
, projects
, each own functions , logically separate , independent.
similar making single $http
request , distributing response many services.
appreciated.
disclaimer - no means rest expert or purist
this question , struggled well. couldn't justify having x number of rest calls display single form/page, x large. solution ended seems work reasonably in case hybrid approach. use aggregates (view models) render forms/pages, these view models server single api call. create/update/delete operations extract actual resource view model on client , post using more restful approach.
this gives me best of both worlds, low number of api calls display page, restful approach on post reduces network overhead.
in addition above use approach saw on breeze.js documentation seems work great well, on application startup load commonly used static lookup data (typically data used dropdowns/select lists) in single lookupsaggregate , cache on clients. model available start , no need refetch them everytime need display dropdown/select lists.
Comments
Post a Comment