-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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.
- Loading branch information
Chris Garrett
committed
Apr 2, 2019
1 parent
0019c1f
commit 6de8129
Showing
3 changed files
with
89 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters