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(useVModel): support clone option #2022

Merged
merged 8 commits into from Sep 5, 2022

Conversation

edumudu
Copy link
Contributor

@edumudu edumudu commented Aug 1, 2022

Description

Fixes side effect when using useVModel with passive flag and with an object as value.
Added a clone option to clone the obj before set to ref

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

Copy link
Member

@antfu antfu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to be a separate clone option that accepts boolean and custom functions. Refer to

/**
* Clone when taking a snapshot, shortcut for dump: JSON.parse(JSON.stringify(value)).
* Default to false
*
* @default false
*/
clone?: boolean | CloneFn<Raw>

@edumudu
Copy link
Contributor Author

edumudu commented Aug 5, 2022

done

@edumudu edumudu requested a review from antfu August 14, 2022 17:54
@antfu antfu changed the title fix(useVModel): remove side effect when using object and passive flag feat(useVModel): support clone option Aug 31, 2022
@antfu
Copy link
Member

antfu commented Aug 31, 2022

Ah, nvm. it seems I was reviewing the wrong diff. This looks good to me in general but I need to hold it for a while long to make sure it behave consistent with #2045

antfu
antfu previously approved these changes Aug 31, 2022
antfu
antfu previously approved these changes Sep 5, 2022
@antfu antfu enabled auto-merge (squash) September 5, 2022 13:42
@antfu antfu merged commit 369e177 into vueuse:main Sep 5, 2022
@edumudu edumudu deleted the fix/remove-side-effect branch September 6, 2022 03:14
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.

None yet

2 participants