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
I've reached a number of dead ends implementing redux-bees and I'm struggling to find a way forward due to two core issues. First, let me explain my requirements:
I want to consume a JSON-API
My API uses OAuth 2 for authentication
I want all the good things from redux-bees like caching, writing data to the store etc.
Unfortunately, it seems thus far that there are a number of inherent issues that prevent me from having this. Most notably being that I may need to refresh a token before the API is requested. To avoid this happening more than once for concurrent requests I've implemented redux-saga to solve
@query() doesn't dispatch any action before the fetch is made
If it did I could:
Watch for the action in redux-saga and defer it until I had a valid token.
Watch for the action in a middleware and stop it if the token needed refreshing.
If I don't use @query I lose all of the good aspects of redux-bees
If I instead:
Dispatch an action like GET_AUTHENTICATED_USER from my component
Watch for that action in redux-saga
Ensure I have a valid token
Call the API directly api.getAuthenticatedUser()
The request works fine, I get back the data but no further dispatches are made that put the data into the store.
I'm at a little bit of a loss over how to proceed without dropping this library. Perhaps I'm missing something. I'd very much appreciate it if @stefanoverna could provide some further insights into the issues I've been facing.
The text was updated successfully, but these errors were encountered:
You could propose a PR with a new action that gets dispached before fetch,
happy to evaluate it!
Il giorno mer 23 gen 2019, 13:04 Adam Butler <[email protected]> ha
scritto:
I've reached a number of dead ends implementing redux-bees and I'm
struggling to find a way forward due to two core issues. First, let me
explain my requirements:
1. I want to consume a JSON-API
2. My API uses OAuth 2 for authentication
3. I want all the good things from redux-bees like caching, writing
data to the store etc.
Unfortunately, it seems thus far that there are a number of inherent
issues that prevent me from having this. Most notably being that I may need
to refresh a token before the API is requested. To avoid this happening
more than once for concurrent requests I've implemented redux-saga
<https://github.com/redux-saga/redux-saga> to solve
@query() doesn't dispatch any action before the fetch is made
If it did I could:
1. Watch for the action in redux-saga and defer it until I had a valid
token.
2. Watch for the action in a middleware and stop it if the token
needed refreshing.
If I don't use @query I lose all of the good aspects of redux-bees
If I instead:
1. Dispatch an action like GET_AUTHENTICATED_USER from my component
2. Watch for that action in redux-saga
3. Ensure I have a valid token
4. Call the API directly api.getAuthenticatedUser()
The request works fine, I get back the data but no further dispatches are
made that put the data into the store.
I'm at a little bit of a loss over how to proceed without dropping this
library. Perhaps I'm missing something. I'd very much appreciate it if
@stefanoverna <https://github.com/stefanoverna> could provide some
further insights into the issues I've been facing.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#66>, or mute the
thread
<https://github.com/notifications/unsubscribe-auth/AADJdcIhMRZN5x2EsuC9NTUhLB9uoxHOks5vGE-wgaJpZM4aOpCJ>
.
I've reached a number of dead ends implementing redux-bees and I'm struggling to find a way forward due to two core issues. First, let me explain my requirements:
Unfortunately, it seems thus far that there are a number of inherent issues that prevent me from having this. Most notably being that I may need to refresh a token before the API is requested. To avoid this happening more than once for concurrent requests I've implemented redux-saga to solve
@query()
doesn't dispatch any action before thefetch
is madeIf it did I could:
If I don't use
@query
I lose all of the good aspects ofredux-bees
If I instead:
GET_AUTHENTICATED_USER
from my componentapi.getAuthenticatedUser()
The request works fine, I get back the data but no further dispatches are made that put the data into the store.
I'm at a little bit of a loss over how to proceed without dropping this library. Perhaps I'm missing something. I'd very much appreciate it if @stefanoverna could provide some further insights into the issues I've been facing.
The text was updated successfully, but these errors were encountered: