redux-query
redux-query copied to clipboard
Pass store to network interface
This passes the store to the network interface so it can be used, for example, to get credentials from the store.
Closes #169.
Please make sure tests pass. I can do a full review of this once the tests are passing.
@rctbusk Thanks, I've managed to get the tests passing now!
@thomasleese, is this something that can be accomplished by creating your own network interface? Instead of modifying the simple one we have in redux query? I am hesitant to make ours more complicated. It is simple and easy to use and if you need something more complicated, I think that can be built out on a per case basis.
@rctbusk Thanks for taking a look. I'll still be creating a custom network interface, but the problem is there ends up being a circular dependency if I try and access the store from within the network interface using the standard store.getState() method. To initialise the store I need the network interface and the network interface needs the store. Our network interface would also need to dispatch to the store if our access token has expired and a new one was acquired using a refresh token.
I could potentially work around this by putting the network interface in the same file as where I initialise the store and declare the store variable higher up in the file above the network interface and then define it below the network interface, but that doesn't feel like a very elegant solution. It also forces me to put lots of code in one file (everything related to the store, the authentication selectors and actions, and the network interface) because javascript doesn't play nicely with importing circular dependencies.
Doesn't seem like there's much appetite for this given my original issue was closed with no response, and I don't use this library anymore, so I'm going to close this PR.