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
Hello,
I would like to define a set of endpoints I can use between two Api types. That way, if I need to alter or change those endpoints, I only need to modify it once for both Apis
For instance, I am looking to make some modules like so:
- src/
- - todo/
- - - todoEndpoints.ts # Set of endpoints for both `todoApi.ts` and `todoApiReact.ts`
- - - todoApi.ts # @reduxjs/toolkit/query
- - - todoApiReact.ts # @reduxjs/toolkit/query/react
I'd import and use the endpoints in a way like so:
For my case, it would be especially useful if I could apply React hooks to my non-react api. Maybe like const myReactApi = reactifyApi(myApi);. Maybe that is already possible?
I understand I can create individual definitions with EndpointDefinition(s), but it doesn't save time if I want to add new endpoints. Might be something I'm missing. How would one best share the same endpoints?
Add React hooks to an already created API instance
(Remember that endpoint definitions don't know anything about hooks - it's the createApi module definition looking at the endpoints and doing something additional with those definitions.
We've had some requests for the ability to add React hooks from a UI-agnostic API instance, and there's an early POC over at #4128 .
For extracting endpoints, your current snippet looks pretty plausible - is there something about that that doesn't work right now?
Hello,
I would like to define a set of endpoints I can use between two
Api
types. That way, if I need to alter or change those endpoints, I only need to modify it once for bothApi
sFor instance, I am looking to make some modules like so:
I'd import and use the endpoints in a way like so:
I'm imagining the endpoints module could look something like this:
For my case, it would be especially useful if I could apply React hooks to my non-react api. Maybe like
const myReactApi = reactifyApi(myApi);
. Maybe that is already possible?I understand I can create individual definitions with
EndpointDefinition(s)
, but it doesn't save time if I want to add new endpoints. Might be something I'm missing. How would one best share the same endpoints?RED-15
The text was updated successfully, but these errors were encountered: