by mpodlasin · 9y ago · 0 comments
const fetchPics = () => dispatch => {
dispatch({ type: PICS_REQUEST });
const cached = deserialize(localStorage.get('pics'));
if (cached && cached.length > 0) return dispatch({ type: PICS_SUCCESS, ...});
return api.get('/pics')
...
}The ability to take your whole application state, save it somewhere (e.g. localstorage), then load it back later is one of the cool things enabled by redux, and it also makes it easier to implement things like time-travel debugging.