New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add '@vue/composition-api' plugin; refactor SelectAddressForm with setup()
; implement #7345
#8118
Add '@vue/composition-api' plugin; refactor SelectAddressForm with setup()
; implement #7345
#8118
Conversation
Use Vue Composition API plugin
This reverts commit 2f10070.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think there are any notable changes to how we'd approach testing the components? It might help with team adoption in general to see how testing is affected by this change even if it's just a matter of composition-friendly code being bundled into modules with smaller and more specific scope being naturally easier to test.
I don't think anything really needs to change in terms of testing the component. You could test the "usables" and the components separately (and mock usable stuff in the context of the component test), but that would be a weaker test, since the two specs could get out of sync. But pragmatically, what I would do is write the "usable" first, give it a stable API, and give it high test coverage. Then integrate it into a component, but only cover a subset of the component specific code, especially if mocking the XHR stuff is a pain. Then together, you have pretty good test coverage and the gaps can be filled in over time. |
15d9e63
to
6146bab
Compare
6146bab
to
2ddc192
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is great. I also tried it and it seemed to work. I have a few points of feedback:
- I've longed for this kind of thing
- Now that it's here, I realize how much of a shift it is
- It'd be great to do almost a mini workshop hack session for people on the team to understand how/when to use this stuff and how to think about it, and also how to understand the "use" metaphor
- I had a hard time getting this branch building at first, and needed to try all kinds of things like
make clean
, switching todevelop
and back and deletingnode_modules
. I don't think it has anything to do with this PR, but just a heads up that I ran into these issues.
import { get, set, useIntervalFn } from '@vueuse/core'; | ||
import { fetchDynamicAddresses } from './api'; | ||
|
||
const Stages = Object.freeze({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice! you learn something new every day, and today I learned about this
Summary
@vue/composition-api@1.0.0-rc9
(seems fine to me and the final should be out sometime in Q3), so we can finally use it and take advantage of its benefits.vueuse
, which is a large library of utility functions that work with the Vue composition api.SelectAddressForm
into two "usables":useDynamicAddresses
anduseSavedAdddresses
, and moving the object exposed from the usables intoSelectAddressForm
'ssetup
function. Why is this cool? Because now all the code related to the two types of addresses can live in their own module, instead of being interlaced in lots of different parts of the Vue component. There are opportunities for cleaning up the API from the usables; I just wanted to do a direct 1-to-1 translation from Vue option -> usable without too much extra refactoring. This is also an opportunity to increase the test coverage of this code without having to worry about the extra complexities of unit testing the Component they live in.turns on the ESLint 'no-shadow' rule (which can cause a lot of confusion when you don't see it 馃槧 )Had to revert it bc there's a lot of this in the codebase (needs followup issue)Video of unreported bug that was fixed:
References
Fixes #7345, and hopefully makes it easier to "fix" #7785 (which seems to be an issue with how static addresses are being filtered within
useSavedAddresses
)Reviewer guidance
setup
and inside the usable's implementation, notice how I need to accessref.value
, but outside of these functions (e.g. inside the template oroptions.computed
, I don't need to do that (since those variables are now reactive proxies). Are there any places in the code where I overlook those caveats?Testing checklist
PR process
Reviewer checklist
yarn
andpip
)Use Vue Composition API plugin