我正在尝试on message ABSdata // <== frame name as defined in the DBC file
{
if (this.DIR == RX)
{
// CarSpeed is a signal belonging to the frame ABSdata
write("The signal value of car speed is %d", this.CarSpeed);
}
}
。
我希望在通过单击按钮调度事件后执行redux-saga
。
console.log("Now Called saga03!!");
import { fork, take } from 'redux-saga/effects';
export function* helloSaga(){
console.log('Hello Saga Root !!');
yield fork(saga01);
yield fork(saga02);
yield fork(sagaFetch);
}
function* saga01() {
console.log('Hello Saga01 !!!');
}
function* saga02() {
console.log('Hello Saga02 !!!');
}
function* sagaFetch() {
while (true){
console.log("Loop Start!!");
yield take('FETCH_SAGA_START');
console.log("Now Called saga03!!");
}
}
import { createBrowserHistory } from 'history';
import { applyMiddleware, compose, createStore} from 'redux';
import { routerMiddleware } from 'connected-react-router';
import createSagaMiddleware from 'redux-saga';
import rootReducer from "../reducers";
import { helloSaga } from "../sagas/saga";
const sagaMiddleware = createSagaMiddleware();
export const history = createBrowserHistory()
export default function configureStore() {
const store = createStore(
rootReducer(history), // Reducers
compose(
process.env.NODE_ENV === 'development' && window.devToolsExtension ? window.devToolsExtension() : f => f,
applyMiddleware(
routerMiddleware(history),
sagaMiddleware
) // Middle Wares
)
);
sagaMiddleware.run(helloSaga);
return store;
}
但是我看不到任何console.log被执行。
我误会了吗?
答案 0 :(得分:0)
最后,我找到了工作一个与失败一个的原因和区别。
Redux Windows.devToolsExtension
导致了此问题。
const store = createStore(
rootReducer(history), // Reducers
compose(
process.env.NODE_ENV === "development" && window.devToolsExtension
? window.devToolsExtension()
: f => f,
applyMiddleware(routerMiddleware(history), sagaMiddleware) // Middle Wares
)
);
我删除了它们。
const store = createStore(
rootReducer(history), // Reducers
compose(
applyMiddleware(routerMiddleware(history), sagaMiddleware) // Middle Wares
)
);
有效。