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

[FEATURE] Removes Chains in Tracked Properties Flag #17951

Merged
merged 1 commit into from
Apr 26, 2019

Commits on Apr 26, 2019

  1. [FEATURE] Removes Chains in Tracked Properties Flag

    This PR updates the tracked properties feature flag to fully remove
    chains. This was primarily is response to core issues we found with
    interop with computed properties, which required us to make computed
    properties and observers more lazy in general.
    
    At a high level, these are the major changes:
    
    * The `getCurrentTracker`/`setCurrentTracker` system was a leaky
      abstraction, since errors could cause a child tracker to never reset.
      In order to make it more bulletproof, it has been changed to
      `track`/`consume`/`isTracking`. We wrap any change to the stack of
      trackers with a `try/catch` to make sure we always clean up in
      `track`. `isTracking` is used only when we don't want to eagerly
      create a tag if there is no tracking context.
    * Observers have been made asynchronous. They now flush during specific
      phases of the runloop - just before render, and potentially after
      render if anything was scheduled (this will begin a new runloop).
      They poll now to check if any changes occured, rather than firing
      synchronously when the change occurs, which is how we made them work
      entirely using tags without chains. Observers inherited from
      EmberObject classes begin polling at the same time as
      `finalizeChains`.
    * Computed properties have been updated to only use chains when
      checking for dirtiness. Since computed properties were lazy before,
      this isn't much of a change overall. Computed properties also no
      longer autotrack, unless they have been marked by a (currently
      private) `_auto()` modifier.
    * Both observers and computeds accomplish this laziness by following and
      reading the tags of their dependencies _after calculation_. They
      entangle all dependencies at this point, _unless_ the dependency is an
      uncalculated computed property. If they encounter one of these, they
      setup _lazy chains_, which will be followed and updated the next time
      the computed property is calculated. This also makes aliases lazily
      observe.
    * Computed properties have also been updated to install a native setter,
      per the track props update RFC.
    * Query parameters use synchronous observers to update various things.
      They should really be refactored, but that's going to take a while.
      In the meantime, we flush the observers synchronously for them
      specifically.
    * A `UNKNOWN_PROPERTY_TAG` system has been added _privately and
      internally only_. This system allows proxies to return a special tag
      that invalidates when their _content's_ properties change. This system
      could be made more public in the future, but it is purposefully
      private for the time being. It was necessary to match existing
      semantics in many tests.
    * A new mandatory setter system has been added. This system is now
      one-way - once a value has been consumed, there is no way to remove
      the setter and "unconsume" it. This is the nature of tags being lazy
      and having no teardown.
    
    There were a few additional changes that were required as well:
    
    * `visit` and `transitionTo` for application tests had to be made
      async in order to work properly with observers. Most of the work
      occured in another PR, but some had to be finished up here.
    * Many, many tests needed to be updated. Most of these were for the fact
      that observers are now async, and required us to wait on the runloop
      settling.
    Chris Garrett committed Apr 26, 2019
    Configuration menu
    Copy the full SHA
    405d423 View commit details
    Browse the repository at this point in the history