Open yurks opened 2 weeks ago
Latest commit: 24a3889738f46750b2ef6af632ee0ba8cebd7ebe
The changes in this PR will be included in the next version bump.
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
This is a really good refactoring. The only thing that bothers me is why the effects in useClientHandle()
were initially manually stopped; I couldn’t find the reason (or I didn’t look well).
Thanks @negezor ☀️
why the effects in
useClientHandle()
were initially manually stopped
The reason of having useClientHandle()
and manually stopping watchers I found is here https://github.com/urql-graphql/urql/pull/3610#issuecomment-2178843530. And the reason it was removed in current PR - I consider this as excessive concern for rare use cases and attempt to bypass vue limitations, which should be completely on users responsibility imho.
But I can agree this kind of removal is overkill for mine "little refactoring", so I'll revert this functionality here. I guess we can found an optimal solution in scope of that PR.
@kitten could you please review the PR?
Summary
This includes https://github.com/urql-graphql/urql/pull/3612, but fixed reactivity loosing here.
In addition, a little refactoring for
use*
composable functions for reducing code duplication and adding more test cases.Set of changes
createRequestWithArgs()
,useClientState()
anduseRequestState()
utils to avoid code duplication.useQuery()
,useSubscription()
anduseMutation()
to use shared utils mentioned above.isReadonly()
check before changingisPaused
variable, as it could be readonly.RemoveonBeforeUnmount
and unwatch handlers, as watcher automatically stopped when the owner component is unmountedflush: 'pre'
in watcher options, as this is default settingunref()
tounwrap()
to avoid confusions with vue functionthen()
handler foruseQuery()
for cleaner code and avoid duplications