Go do what you want with it. Nice. Don't use it for forms. For updating form state. Yeah. All right.
Is RTK query always the way to go, or are there cases where using just plain fetch is better? So, RTK, well, that's a slightly false question. RTK query, on the one hand, it's a general-purpose async state manager. TK Dodo, the author of React query has written some posts saying it's not a data fetching library, it's an async state manager, because it's just here's a promise, track the status, cache the result. RTK query is the same thing. We default to having a fetch wrapper as the default way to use it, but you can use it for any promise async function at all. We certainly teach RTK query as the default way to do any data fetching in a Redux application. It's a tool, it has its limits, and there are probably some edge cases where you might need to write some thunks or some other logic instead.
That actually brings on to a further question down, which actually sort of gets outside of that data fetching, I guess, and asking, like, would Redux be good in back-end for like Web sockets and gaming at all? So that goes to what I was saying earlier. Redux itself, the core is entirely UI agnostic. We've always assumed, like, 90% of our users will use it with React, but you can use Redux anywhere that JavaScript will run, with or without any UI. And so, yeah, I've seen people use it, like, in Discord bots to keep track of status. Yeah, and Web sockets doesn't make a difference or you write your own... It's logic, you dispatch actions, it runs. Nice.
Redux Saga lets me abort fetching, is that possible in RTK query? Let's see, what? Redux Saga lets me abort fetching, is that possible? Not exactly. So this has actually come up pretty frequently in the RTK query related issues and feature requests. Our stance so far has been that there isn't enough reason to abort a data fetch because the result will get cached and even if a component no longer says it needs that data right now, you might come back and need it later, it's just another cache entry, and if no component needs it, it'll get garbage collected later. We have had enough requests for aborting, like, literally aborting a fetch request that it's something we might look at adding in a future version. Awesome, that's good to hear. And if you want that, I guess send in a request as well? There's no more issues, no more issues. Just a thumbs up on an existing one? Yes, please. No more new issues on that, cool. Oh, this is interesting.
Comments