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][FEAT][Tracked Properties] Adds Arg Proxy Feature Flag #17835

Merged
merged 2 commits into from
Apr 22, 2019

Commits on Apr 22, 2019

  1. add unstable args test

    Chris Garrett committed Apr 22, 2019
    Configuration menu
    Copy the full SHA
    0f6afed View commit details
    Browse the repository at this point in the history
  2. [BUGFIX] Adds Arg Proxy feature for tracked properties

    Currently, we pass a captured snapshot of arguments to the custom
    component manager and expect users to update their `args` and trigger
    notifications, dirtying any getters that rely on `args`. This is
    problematic for a few reasons:
    
    1. It's fundamentally less efficient, since every getter on a component
       will invalidate any time _any_ of the arguments on the component
       changes. This may not be a huge deal in most components, but it could
       be problematic at scale.
    2. Upstream components will currently rerender if anything changes
       downstream of them.
    
    The second problem is more of an issue here. The crux of the issue is
    that as we are rendering, we must somehow dirty the `args` object in
    order for getters to invalidate. Currently, there are two ways of doing
    this:
    
    1. Dirtying the tag and bumping the global revision count. This results
       in the component itself being dirtied, which causes arguments to be
       assigned again on the next render, which dirties everything again.
    2. Setting the argument's tag to `CURRENT_TAG`, as we do in Glimmer.js.
       This always returns the _latest_ revision though, which means that we
       are _always_ dirty.
    
    This issue can crop up in many forms and leads to infinite rerender bugs
    when it does.
    
    The solution proposed here is to instead use a Proxy (or an object with
    manually defined getters on platforms which do not support Proxy) to
    wrap `args`. This allows us to directly access the references that
    represent the arguments, and push their tags onto the autotrack stack as
    accessed. Everything entangles properly, and we only rerender or
    recalculate a getter when needed.
    
    Alternatively, we could add a way to set the `args` tag to _exactly_
    the current revision as the component is rendering. This would solve the
    problems of upstream invalidations, but would not solve the issue of all
    getters on a component invalidating each render.
    Chris Garrett committed Apr 22, 2019
    Configuration menu
    Copy the full SHA
    af9ddaf View commit details
    Browse the repository at this point in the history