|
|
|
|
|
by andreareina
3291 days ago
|
|
I'm only passingly familiar with redux (read the tutorial + parts of the docs a few times, never actually used it), where is the problem? As I understand it the status of the request is encoded in the store's state. The (de)serialization can be handled as part of the fetch: 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.