ReactJS – Redux-Saga Unable to capture the operations sent by the store booster

I need to use store enhancer (reactReduxFirebase, from react-redux-firebase) in my redux application. This enhancer schedules an action and it looks more or less like this (Very simplified):

const reactReduxFirebase = (next) => {
return (reducer, initialState, middleware) => {
const store = next(reducer, initialState, middleware);
store.dispatch({
type:'DUMMY_ACTION'
});
return store;
}< br />}

// usage
const sagaMiddleware = createSagaMiddleware();
const middleware = [sagaMiddleware];
const store = createStore(
reducer,
initialState,
compose(
applyMiddleware(...middleware),
reactReduxFirebase
)
);
sagaMiddleware.run( sagas);

// sagas.js
function* handle(action) {
console.log(action);
}

function* saga() {
yield takeEvery('*', handle);
}

export default saga;

I want saga to listen to all Action and console.log them, but it will not capture the’DUMMY_AC’ scheduled by the enhancer TION’, because it is scheduled before saga starts listening (sagaMiddleware.run(sagas);). From the redux-saga documentation, it seems that saga must be run after applyMiddleware, so I cannot run saga before the enhancer. Is there any way to make it work, so the legend will also capture an action from the enhancer?

try this legend

function* log(action) {
while (true) {
yield take('*');
console.log(action);
}
}

export default function* root() {
yield all([call(log)]);
}

Just to see if it works and then You can try to move to takeEvery, I did have a problem, and create a handle specific to saga work

I need to use store enhancer(reactReduxFirebase , From react-redux-firebase). This enhancer schedules an action, it looks more or less like this (very simplified):

const reactReduxFirebase = (next) => {
return (reducer, initialState, middleware) => {
const store = next(reducer, initialState, middleware);
store.dispatch({
type:'DUMMY_ACTION'
});
return store;
}
}

// usage
const sagaMiddleware = createSagaMiddleware() ;
const middleware = [sagaMiddleware];
const store = createStore(
reducer,
initialState,
compose(
applyMiddlewa re(...middleware),
reactReduxFirebase
)
);
sagaMiddleware.run(sagas);

// sagas.js
function* handle(action) {
console.log(action);
}

function* saga() {
yield takeEvery('*', handle);
}

export default saga;

I want saga to listen to all actions and console.log them, but it will not capture the’DUMMY_ACTION scheduled by the enhancer ‘Because it is scheduled before saga starts listening (sagaMiddleware.run(sagas);). From the redux-saga documentation, it seems that saga must be run after applyMiddleware, so I cannot run saga before the enhancer. There is What method can make it work, so the legend will also capture an action from the enhancer?

Try this legend

function* log(action) {
while (true) {
yield take('*');
console.log(action);
}
}

export default function* root() {
yield all([call(log)]);
}

Just to see if it works and then you can try to move to takeEvery, I did have a problem And create a handle specific to saga work

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 5941 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.