In an Angular 4 app using Redux (with ngrx-store), I have the following:
a smart component that calls a service
this.contentService.update(this.content).subscribe( data => {
//output some success message
});
a service that calls an API and then dispatch an action
update(content: Content) {
return this.http.put(`http://someendpoint/contents.json`, { content })
.map( (updated_content: Content) => {
this.store.dispatch( { type: 'SOME_KEY', payload: updated_content } );
return updated_content;
});
}
this approach is working really well, no problem. But I don't know if this is the right way: would it be better to let the component handle the response of the API an dispatch the action to the store? Should I separate this? What are the pros and cons? I can't find a good article about this.