Skip to content

Safety of query decorators #2570

Closed Answered by sorvell
steverep asked this question in Q&A
Feb 18, 2022 · 3 comments · 5 replies
Discussion options

You must be logged in to vote

This behavior is part of Lit's asynchronous rendering model. Lit's reactive update cycle is asynchronous because it generally results in ergonomic code that is naturally efficient. For example, where foo and bar are reactive properties el.foo = 5; el.bar = 6; is simple to write and causes the element to efficiently update/render only once.

The tradeoff is that if you do have an API that cares about the rendered state of an element (as in your use case), you have to use await el.updateComplete.

Since the asynchronous model is core to the design and very important for efficiency, we have avoided adding APIs that automatically trigger synchronous rendering, preferring instead to recommend us…

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
3 replies
@steverep
Comment options

@p-ob
Comment options

@steverep
Comment options

Comment options

You must be logged in to vote
2 replies
@steverep
Comment options

@GHNewbiee
Comment options

Answer selected by steverep
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants