Closed nhwilly closed 3 years ago
Did u find any solution? @nhwilly
@vahidngh I really loved Flutter, but the project changed and we moved to another platform. I believe the singleton approach was what I finally used, but there are other ways to solve this, I'm sure. If you hit up Felix on the bloc team, he for sure can point you in the right direction. He's a really great guy and authored the bloc package. If anyone can direct you, it's him.
Also, remi
and others in the community are unbelievably supportive. Sorry I didn't come up with some solution I can tell you abot.
Best of luck.
You're such a great guy! Thanks a lot and hope you the bests in any major.
In my app, I have an authentication
dataSource
designed to retrieve JWT access tokens and refresh tokens from my server. The access token has to be supplied on every call.However, in my server calls, I may return a 401 and automatically use the refresh token to refresh the access token with a server call and then retry the original call.
When this happens, the contents of the access token will change. That could possible affect other things (like permissions, etc.). In addition, the new tokens will have to be saved to storage.
To do that, the authentication
bloc
will have a new event ofrefreshed
and that might effect other things. The various other parts of the app can then reflect the new access token values.So, do I create a singleton authentication
bloc
andadd
therefreshed
event to it when this happens from inside the API? That sounds right. That's the way I wrote it, but it doesn't seem "clean".