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

[BUGFIX release] Ensure hash properties are reified lazily #1298

Merged
merged 1 commit into from
Apr 27, 2021

Commits on Apr 22, 2021

  1. [BUGFIX] Ensure hash properties are reified lazily

    `(hash)` previously had two different types of behavior, one where it
    was used as a reference and could get individual properties lazily, and
    one where it was fully reified and exposed in JS. The lazy nature of
    hash was very useful as it prevented having to realize the full cost of
    each reference immediately, and it also meant that some values could
    be accessed in conditionals and run assertions just in time. For
    example, if someone was using a component that was loaded lazily via
    an engine, you could render the component on a hash within a conditional
    and it would not cause an error (because the component did not exist):
    
    ```hbs
    <SomeComponent as |api|>
      <api.eagerComponent/>
    
      {{#if this.displayLazy}}
        <api.lazyComponent/>
      {{/if}}
    </SomeComponent>
    ```
    
    This PR restores this ability by having `(hash)` return a proxy rather
    than an object, which allows us to access each individual value without
    reifying the references immediately. For backwards compatibility, we
    also allow users to set values on the proxy, so long as they are not
    setting any of the values defined on the proxy initially, since those
    are read-only references.
    Chris Garrett committed Apr 22, 2021
    Configuration menu
    Copy the full SHA
    4732b3f View commit details
    Browse the repository at this point in the history