When a user logs out, I want to reset the entire store to it's initial state. I want to do this because I don't want to store any items in memory after they lost the authentication context.
I think this makes the most sense to be implemented as a middleware, so I started as follows
import { LOGOUT } from 'app/actions/auth';
export default function authMiddleware(store) {
return action => next => {
if (action.type === LOGOUT) {
// ???
}
next();
}
}
Specifically, I am having a hard time finding the initial state of the store on the initial instantiation of the application.
Is there a standard way to do this in redux?