dimanche 12 juin 2016

Redux, right way to deal with web API calls

Where ajax calls should be executed when using Redux with Angular 2?

I see two possibilities, first of that Service classes handles ajax call and other asynchronous operations and delegates the resulting Observable result for store to dispatch. This means that store is just responsible to store the byte state of an application, and Actions are mere carriers to transfer the bytes to store, without executing any logic, validation etc. This was my first impression Redux - Just create a new state based of an instruction and a payload, which is a result of an logical operation executed outside of Redux domain.

However, as I continued reading advanced chapters of Redux official documentation (Async actions and middleware), I got impressions that dispatching actions actually could execute logic, and in point of fact ALL program logic SHOULD be executed as a result of dispatching an action.

Now I'm very confused how the Reducers, Actions and store is intended to use, and what is their relation to events, local service calls, web API calls, routing etc.

Aucun commentaire:

Enregistrer un commentaire