angularjs - Angular 2 architecture for server-side communication -
learning angular 2. recommended file structure having components communicating server?
so feature, todo feature. may have main todo-component
, todo-list-component
, todo-item-component
, new-todo-component
, todo-service
(and more).
then there feature, personal activity timeline, takes several source (including new , finished todos) , present user. may have same type of files, different not combine them generic ones: main timeline-component
, timeline-list-component
, timeline-item-component
, timeline-service
.
then want both todo , timeline features communicate server. since both access partly same data, perhaps idea have backend-service
take care of server communication both features.
but how should components data it's need? should todo components ask todo-service in turn asks backend-service
(and similar timeline components)? or should components better use backend-service directly, example todo components use backend-service
backend stuff , todo-service
, other things naturally put in service? since async , there observables involved (which in first case need sent on multiple "steps" somehow), perhaps latter simpler/cleaner approach?
ideally component should use proper service pipe data flow observables. if instance @ chat application example can see each service has clear responsibility data management. wouldn't allow component access generic http service need host logic communicate server: component doesn't care data source, shows data.
Comments
Post a Comment