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(reactivity): proxyRefs method and ShallowUnwrapRefs type #1682

Merged
merged 3 commits into from
Jul 28, 2020

Commits on Jul 22, 2020

  1. feat(reactivity): proxyRefs method and ShallowUnwrapRefs type

    BREAKING CHANGE: template auto ref unwrapping are now applied shallowly,
    i.e. only at the root level.
    
      This change aims to ensure that non-ref values referenced in templates
      retain the same identity with the value declared inside `setup()`
      regardless of whether it's wrapped with `reactive` or `readonly`.
    
      The breaking case is that given the following:
    
      ```js
      setup() {
        return {
          one: ref(1),
          two: {
            three: ref(3)
          },
          four: 4
        }
      }
      ```
    
      After this change, `{{ one }}` in the template will still render `1`,
      but `{{ two.three }}` will no longer be auto unwrapped as `3`.
    
      A common case where this could happen is returning an object of refs
      from a composition function. The recommendation is to either expose
      the refs directly, or call the newly exposed `proxyRefs` on the object
      so that the object's refs are unwrapped like root level refs. In fact,
      `proxyRefs` is also the method used on the `setup()` return object.
    
      This also makes non-ref properties in the returned objects non-reactive,
      so mutating `four` from the template will no longer trigger updates.
    yyx990803 committed Jul 22, 2020
    Configuration menu
    Copy the full SHA
    3d98df5 View commit details
    Browse the repository at this point in the history
  2. test: fix dts test

    yyx990803 committed Jul 22, 2020
    Configuration menu
    Copy the full SHA
    f7b8cf3 View commit details
    Browse the repository at this point in the history

Commits on Jul 23, 2020

  1. Configuration menu
    Copy the full SHA
    4b522d3 View commit details
    Browse the repository at this point in the history