16.10 Using Action Creators And Get State
result.js
src\store\actions\result.js
import * as actionTypes from "./actionTypes";
export const saveResult = (res) => {
// const updatedResult = res * 2
return {
type: actionTypes.STORE_RESULT,
result: res,
};
};
export const storeResult = (res) => {
return (dispatch, getState) => {
setTimeout(() => {
const oldCounter = getState().ctr.counter;
console.log(oldCounter);
dispatch(saveResult(res));
}, 2000);
};
};