I am using v2 and I try to implement an authentication flow. My purpose is to check if isLoggedIn flag in store is true or false. For this, I want to implement a Router hook (or pipeline, as it is called in v1) but I could not figure out how to do it exactly. connectTo won’t work, I assume because certain lifecycle methods such as bind does not exist for hooks. So any help ( or recommendations for better approaches ) is appreciated
You might have already done this, but have you taken a look at the v2 docs? Towards the end there is a section about authentication using lifecycle hooks .
Hey Ivan. Thanks for response
Yes, I looked at the given example and although it is a good example, I would still want to learn a good way to access the global state.
if you’re talking about the store plugin, inject the store in the hook, subscribe and get the state into a prop and use it for whatever you need it