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

Move morphing out of render phase #8

Open
aleclarson opened this issue May 20, 2023 · 0 comments
Open

Move morphing out of render phase #8

aleclarson opened this issue May 20, 2023 · 0 comments
Labels
enhancement New feature or request feature: morphing Related to element morphing major Breaking change

Comments

@aleclarson
Copy link
Contributor

aleclarson commented May 20, 2023

In preparation for error boundary support (#7), we need to ensure all internal mutation is moved out of the render call (i.e. no morphing a child element during render, including component boundaries).

  1. Use a @preact/signals observer effect (hereon referred to as "the observer") to capture observed values during render (as we already do), but change what happens when a change is detected. Instead of rerendering synchronously, tear down the observer and schedule an update on the next microtask (in the future, we could do intelligent scheduling).

  2. Assign internal context (on the component scheduled to update) that tracks the root component in the case of multiple components being invalidated in the same microtask. Start by rerendering the root component, then rerender top-down any remaining scheduled components (as memoization may prevent the full update from the root). Any remaining components become root components of their own update.

  3. While updating the components, collect any nodes that require morphing. Once all components have updated, morph them all at once.

@aleclarson aleclarson added enhancement New feature or request major Breaking change labels May 20, 2023
@aleclarson aleclarson added the feature: morphing Related to element morphing label Aug 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature: morphing Related to element morphing major Breaking change
Projects
None yet
Development

No branches or pull requests

1 participant