I've a two sagas to be called onto the same page.But then only one saga results are seen. The other saga is not executing I don't see the results.

AdminFolder

dashboard.js

               const mapStateToProps=state=>{
                console.log(state)
                return{   
                    dataSales:state.salesDataReducer,
                    mostBrought:state.mostBroughtReducer
                }
                };

                const mapDispatchToProps = {
                    getSales:getSales,
                    getMostBrought:getMostBrought
                };

rootSaga/rootSaga.js

                import actionWatcherSalesData from '../adminDashboard/salesDataSaga';
                import actionWatcherMostBrought from '../adminDashboard/mostBroughtSaga';
                import {all,call} from 'redux-saga/effects';



                export default function *rootSaga(){
                    yield all([
                    call( actionWatcherSalesData), //works
                    call(actionWatcherMostBrought)// this saga doesn't call up no data found 
                    ]);
                }

                    export default function *rootSaga(){
                    yield all([
                    fork( actionWatcherSalesData),
                    fork(actionWatcherMostBrought)//doesnt work
                    ]);
                }

saga1.js

 yield takeLatest(GET_SALES_DATA,getSales)

saga2.js

 yield takeLatest(GET_MOST_BROUGHT_DATA,getMostBrought);

Is it takeLatest which is causing the issue?

1)As its the same page data both the call must happen async but the second saga call is not called ? 2)I have a doubt that for my application on other page I've a button only on click it must call the saga should that be include here?

In this call,fork,all is not working. PLease lemme know this where I'm going wrong.have I missed onto to something? Any help is appreciated.

1 Answers

0
Community On

My bad the imports were wrong

The following works like a charm :)

  export default function *rootSaga(){
   yield fork(actionWatcherSalesData)
   yield fork(actionWatcherMostBrought)
   }