posts/react-context-mutex #26
Replies: 1 comment 1 reply
-
Hi, I'm trying to do a similar thing and I came across your library. However, I don't know if it's because I'm still fairly new to React hooks, not great with async/await, or just because I currently have covid and can't concentrate very well but I'm having trouble trying to make it do the thing I'm trying to do. Maybe you can give some advice? Basically, I have a component that calls an API for some data - pretty simple. However, the auth for that API is through temporary tokens. Basically, request a temporary token, then request your data with that token and you're good. But I don't want to create a temporary token for every single instance of this react component in my app. I'd like a way for all these requests to "await" a single token request, then all continue once that finishes. Thinking about "locking" and "mutex-ing" the token request led me to your library and I was able to force just a single token request to happen - but the Let me know if you have any thoughts and if I'm (probably) thinking about this all wrong. Thanks! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
posts/react-context-mutex
Make sure you can lock a process from running multiple times and unlock it when it's allowed to run again
https://www.marcveens.nl/posts/react-context-mutex
Beta Was this translation helpful? Give feedback.
All reactions