You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It could happen that we logout in the Navbar, and this would be reflected in the Navbar topbar (we would see login button), but other micro apps would not know about this event, unless they directly call getAuthUserTokens again.
Switch to the first tab where it is shown as logged-in.
Wait until the current token expires. At that moment Navbar would try to refresh the token, but as we are already logged-out, it could not refresh the token and would update the status of Navbar as logged-out: use would disappear and login button would be shown.
There are several ways to solve this. But it feels that the most consistent and robust way if Navbar would provide some event when a user is logged-out.
For example, it could export a method like subscribeToLogout(callback) so we could subscribe to the event of logout, and the callback should be invoked by the Navbar when user is logged out. And method unsubscribeFromLogout(callback).
Or it could be implemented a more general way by having 2 exported method in Navbar:
subscribe(evenName, callback) - subscribe to some event with name evenName
unsubscribe(eventName, callback) - unsubscribe to some event with name eventName and callback
This solution has one downside. The child app would have to always manually unsubscribe from all the events it subscribed to avoid memory leaks. So it would be better if we implement some automation logic that would unsubscribe child apps from all the events it subscribed to when the child app is unmounted. Though I'm not sure if it could lead to some edge cases or downsides.
The text was updated successfully, but these errors were encountered:
Background
It could happen that we logout in the Navbar, and this would be reflected in the Navbar topbar (we would see
login
button), but other micro apps would not know about this event, unless they directly callgetAuthUserTokens
again.In particular, we have this issue in TaaS Admin App topcoder-platform/micro-frontends-taas-admin-app#52
How to reproduce
Logout
Wait until the current token expires. At that moment Navbar would try to refresh the token, but as we are already logged-out, it could not refresh the token and would update the status of Navbar as logged-out: use would disappear and
login
button would be shown.Solution
There are several ways to solve this. But it feels that the most consistent and robust way if Navbar would provide some event when a user is logged-out.
For example, it could export a method like
subscribeToLogout(callback)
so we could subscribe to the event of logout, and thecallback
should be invoked by the Navbar when user is logged out. And methodunsubscribeFromLogout(callback)
.Or it could be implemented a more general way by having 2 exported method in Navbar:
subscribe(evenName, callback)
- subscribe to some event with nameevenName
unsubscribe(eventName, callback)
- unsubscribe to some event with nameeventName
andcallback
This solution has one downside. The child app would have to always manually unsubscribe from all the events it subscribed to avoid memory leaks. So it would be better if we implement some automation logic that would unsubscribe child apps from all the events it subscribed to when the child app is unmounted. Though I'm not sure if it could lead to some edge cases or downsides.
The text was updated successfully, but these errors were encountered: