samedi 11 juin 2016

Redux vs services in Angular 2

I want to ensure I have understood Redux right. My understanding is that it will store the complete state of an application (including all subsystems) like models of all components and cache of fetched data and user generated data. Does that mean I should never use service to load/save state of an component by it's model's id?

I'm making an quiz application, which consist of components like Quiz, Category, Question and Choice. Currently each component calls the web API to fetch data and maintains it's own state itself or with the aid of an service which keeps track of everything by id fields.

I have dedicated service called AnswerService to maintain the state of selected choices, where each Choice component fetches it's state when rendered.

Does migrating to Redux means all of this will be moved to store, and virtually all service will be stateless and dispatch directly to store, and respectively all component models are subscribed from store?

Aucun commentaire:

Enregistrer un commentaire