Skip to content
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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(reactivePick): allow ref picks #461

Closed

Conversation

TimonLukas
Copy link

Closes #460.

This PR adds the ability to pass not only variadic keys, but also an array of keys or a ref array of keys. This is done while (I think) keeping BC. Tests work fine on 3, on 2 Jest completely hangs up got me, even with --runInBand --detectOpenHandles --forceExit. I hope these are the usual Jest shenanigans and not a real problem.

@TimonLukas
Copy link
Author

TimonLukas commented Apr 17, 2021

It appears the Jest problems are not local to my computer. I'll try to debug them, but help would be greatly appreciated - this seems really weird!

I'm reasonably sure that we're hitting this issue. Seems like there isn't much we can do except wait for it to be fixed, at least I have no idea how to approach it... For now we could maybe add a safeguard, i.e. check whether we're in Vue 2, and if so throw an error when using the function.

Update: I've managed to make it work. Setting { flush: 'sync } on watchEffect makes it not pick up on removing keys, but it does fix the infinite loop. According to the docs sync is a lot slower than the default pre, so we only use that if necessary. To fix deletions not being executed I added an extra watch just on Vue 2 which implements this. Somehow here { flush: 'sync' } does exactly what we need! :D

@antfu
Copy link
Member

antfu commented Apr 19, 2021

Thanks for your contributions, but I am afraid if it's a good idea to introduce such complexity to these simple utils. I saw you found a solution for your problem #460 (comment), do you still feel these changes needed? (since that approach is much cleaner 👍)

Thanks!

@TimonLukas
Copy link
Author

I think it could still be useful, but you're right that the increased complexity probably isn't worth it :)

@antfu
Copy link
Member

antfu commented Apr 20, 2021

Maybe we can further break it down into smaller functions to compose it. A good one might be replaceReactive there will delete extras keys when the target does not have them. So we can separate the concern and make the codebase more maintainable. WDTY? If you want, feel free to open a new PR. Thanks

@antfu
Copy link
Member

antfu commented May 7, 2021

Thanks for contributions. Close for now.

@antfu antfu closed this May 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feature] reactivePick: support computed keys
2 participants