Don't use Pinia for requestData even in development #1050
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR removes Pinia from
requestData
entirely.requestData
was designed to use Pinia in development (never production). However, we haven't been using Pinia for a while due to #787. That means that this PR doesn't have a huge practical effect. However, it simplifiesrequestData
and opens the door to some extensions to it. For example, for #1044, I want to be able to create an arbitrary number ofrequestData
resources, yet I'm not sure that that's something that would play well with our Pinia setup.I think it's helpful to remember why we're using Pinia in the first place. We don't need Pinia for reactivity, because we get that out of the box with Vue 3. Instead, the main value-add of Pinia is logging. Specifically, Pinia provides a nice interface within Vue DevTools to see what changes have been made to
requestData
and which components specifically made those changes.When I created
requestData
, it felt important for it to offer robust logging.requestData
was a replacement for Vuex, which had its own mechanism for logging changes. At first, I started out writing my own logging mechanism. However, once I realized that Pinia integrated with Vue DevTools, using Pinia seemed like a reasonably straightforward and feature-rich way to incorporate logging intorequestData
.It's been a while since then, and it's now clear that Pinia's logging hasn't proven to be especially useful. I expected there to be more issues with
requestData
, but thankfully, they just haven't come up that often. Given the infrequency of issues, it's uncommon that we need to troubleshootrequestData
. When we do,console.log()
is usually enough to do the job.So it doesn't seem like Pinia is particularly useful. Yet at the same time, it also comes with costs:
patch()
pattern that's removed in this PR exists only for the sake of logging. It helps to group together multiple changes as a single event within Pinia logging. However, it requires explanation, especially for newcomers to the codebase.requestData
is harder to follow.requestData
resources. TheAsyncRoute
component is an example of that that you can see in this PR.What has been done to verify that this works as intended?
Tests continue to pass.
Before submitting this PR, please make sure you have:
npm run test
andnpm run lint
and confirmed all checks still pass OR confirm CircleCI build passes