Reputation: 969
I have a problem with redux-sage. Cannot manage to subscribe to action. I have this setup for store
import { createStore, applyMiddleware, compose } from "redux"
import createSagaMiddleware from "redux-saga"
import rootSaga from "../config/rootSaga"
import rootReducer from "../config/rootReducer"
const effects = []
let composeEnhancers = compose
if (process.env.NODE_ENV === "development") {
composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ // eslint-disable-line no-underscore-dangle
}
const sagaMiddleware = createSagaMiddleware()
effects.push(sagaMiddleware)
const store = createStore(rootReducer, {}, composeEnhancers(applyMiddleware(...effects)))
sagaMiddleware.run(rootSaga)
export default store
Looks like the saga middleware does not work. I see console.log from my rootSaga but when a redux action is happening the saga doesn't work
export default function* searchRootSaga() {
console.log("searchRootSaga") // I see this on start
yield all([fork(throttle, 100, SEARCH.GET.REQUEST, getSearchThis)])
}
export function* getSearchThis(action) {
console.log("getSearchThis") // I dont see this
try {
// const response = yield call(API.getSearch, query)
const response = dummy_data
yield put(getSearchSuccess(response))
} catch (e) {
yield put(getSearchFailure("Server Err"))
}
}
React dev tools shows SEARCH.GET.REQUEST action but saga is not working. What I'm doing wrong?
Upvotes: 0
Views: 1254
Reputation: 4975
I think throttle is a non-blocking effect itself. So you don't need to fork it. Try:
yield throttle(100, SEARCH.GET.REQUEST, getSearchThis)
Upvotes: 3