Skip to content

Synchronise component renders.#396

Merged
hayleigh-dot-dev merged 3 commits intomainfrom
component-render-sync
Nov 1, 2025
Merged

Synchronise component renders.#396
hayleigh-dot-dev merged 3 commits intomainfrom
component-render-sync

Conversation

@yoshi-monster
Copy link
Contributor

If a component's view renders another component, this child component will receive a property or attribute change event synchronously, but then queue an animation frame one frame later.

This change introduces a global counter keeping track of nested updates like this and renders the child component synchronously instead if that happens, removing that one frame delay.

Copy link
Collaborator

@hayleigh-dot-dev hayleigh-dot-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this solution is less clear than the previous immediate parameter to dispatch? We know the only source of immediate renders would be an attribute/property change or a context provide, I think that would be clearer what do you think?

@yoshi-monster
Copy link
Contributor Author

yoshi-monster commented Nov 1, 2025

The idea behind the counter was that we really want to always render on animation frame; this solution does not work when other frameworks trigger updates though, so I think always rendering synchronously after attribute/property/context changes is an ok compromise.

I don't really like how this is rendering the component for every attribute/property that got changed, should be do something about that?

@hayleigh-dot-dev
Copy link
Collaborator

I don't really like how this is rendering the component for every attribute/property that got changed, should be do something about that?

Yeah I agree but I'm not super sure there's much we can do about it? I thought about queuing a microtask so all attribute (etc) change messages get batch-processed but then does this introduce some weird very niche timing edge cases for the component im not sure.

@hayleigh-dot-dev hayleigh-dot-dev merged commit 657965c into main Nov 1, 2025
1 check passed
@hayleigh-dot-dev hayleigh-dot-dev deleted the component-render-sync branch November 1, 2025 02:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants