Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Order of reducer and saga

Tags:

redux-saga

When dispatching an action is the order when it arrives to a reducer and a saga guaranteed?

Can I rely on that it

  1. first enters the reducer
  2. then the saga?

Reducer:

 function reducer(state, action) {

    switch (action.type) {
       case 'MY_ACTION':
       // decorate action so that an epic doesn't have to take data from store
       action.ports = state.itemsModified;                 
       return state;
     }
    }

Saga:

export function* sagaUpdatePorts() {
    yield* ReduxSaga.takeEvery(actions.GRID_PORTS_ASYNC_UPDATE_PORTS, updatePorts);
}

function* updatePorts(action) {
    const {response, error} = yield SagaEffects.call(portsService.updatePorts, action.ports);
}
like image 844
Amio.io Avatar asked Jul 27 '16 08:07

Amio.io


1 Answers

Yes. The action hits the reducer first then Sagas.

like image 173
Yassine Elouafi Avatar answered Oct 18 '22 14:10

Yassine Elouafi