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
At the moment, we send requests in one of three different ways:
Using the request() method of a requestData resource
Using a method from the request mixin
Using http in the container directly (http is set to axios)
(1) and (2) are both common. (3) is uncommon and maybe only happens for the logout request.
(1) and (2) do a lot of the same things, for example, around error handling, so they have some near-duplicate code. That's mostly a historical artifact, reflecting that things like showing an alert worked differently within the Vuex store vs. within components. We no longer have a Vuex store, and everything can now use the container to access app-wide state, so I think we're now well positioned to move that shared logic into a function that both requestData and the mixin can call. Once we have a function like that, cases like (3) could also call it.
I still think it makes sense to have multiple ways of sending requests. requestData resources have one way of storing request state, but components need a separate mechanism. And requests sent by resources vs. requests sent by components have slightly different lifecycles: they can be canceled in different ways. So the goal of this issue isn't to remove all distinctions between these different ways of sending requests, but rather to reduce duplicate code and to remove distinctions that aren't necessary. For example, we used to document that the request module of the Vuex store was strictly for GET requests, while the request mixin was for non-GET requests. However, requestData resources are now able to send non-GET requests, and I think the request mixin should be allowed to send GET requests as well. (Not that we should necessarily encourage that pattern given that components can now create local resources, which will usually be the most convenient approach.)
The text was updated successfully, but these errors were encountered:
At the moment, we send requests in one of three different ways:
request()
method of arequestData
resourcerequest
mixinhttp
in the container directly (http
is set to axios)(1) and (2) are both common. (3) is uncommon and maybe only happens for the logout request.
(1) and (2) do a lot of the same things, for example, around error handling, so they have some near-duplicate code. That's mostly a historical artifact, reflecting that things like showing an alert worked differently within the Vuex store vs. within components. We no longer have a Vuex store, and everything can now use the container to access app-wide state, so I think we're now well positioned to move that shared logic into a function that both
requestData
and the mixin can call. Once we have a function like that, cases like (3) could also call it.I still think it makes sense to have multiple ways of sending requests.
requestData
resources have one way of storing request state, but components need a separate mechanism. And requests sent by resources vs. requests sent by components have slightly different lifecycles: they can be canceled in different ways. So the goal of this issue isn't to remove all distinctions between these different ways of sending requests, but rather to reduce duplicate code and to remove distinctions that aren't necessary. For example, we used to document that therequest
module of the Vuex store was strictly for GET requests, while therequest
mixin was for non-GET requests. However,requestData
resources are now able to send non-GET requests, and I think therequest
mixin should be allowed to send GET requests as well. (Not that we should necessarily encourage that pattern given that components can now create local resources, which will usually be the most convenient approach.)The text was updated successfully, but these errors were encountered: