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(computedAsync): introduce shadow option #2616

Merged
merged 3 commits into from Jan 5, 2023
Merged

Conversation

xiankq
Copy link
Contributor

@xiankq xiankq commented Jan 5, 2023

Description

Use shallowRef and mark the return value as readonly to conform to the computed ideas.

issues #2117


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.

@antfu
Copy link
Member

antfu commented Jan 5, 2023

shallowRef should be an options, just like:

shallow = true,
throwError,
} = options ?? {}
const state = shallow ? shallowRef(initialState) : ref(initialState)

We need to make it default to false to avoid breaking change, and change to true in another PR aiming for the next major version

@xiankq
Copy link
Contributor Author

xiankq commented Jan 5, 2023

hi,I've added shallow to the options, for which I also provided an update to the docs
code: 88de7b2
docs: b627a94

@xiankq
Copy link
Contributor Author

xiankq commented Jan 5, 2023

I'm also preparing the next version : #2621

@xiankq xiankq changed the title feat(computedAsync): shallow readonly feat(computedAsync): Use shallowRef Jan 5, 2023
@antfu antfu changed the title feat(computedAsync): Use shallowRef feat(computedAsync): introduce `shadow Jan 5, 2023
@antfu antfu changed the title feat(computedAsync): introduce `shadow feat(computedAsync): introduce shadow option Jan 5, 2023
@antfu antfu merged commit a065637 into vueuse:main Jan 5, 2023
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