Async logic in the lit element lifecycle/shouldUpdate #3697
Replies: 1 comment
-
I tend not to use Lit's reactive lifecycle to manage async stuff. Not everything has to be a reactive property; I generally use them only for things that should directly trigger a re-render. In the case of your example, that would only be Here's a modification of your example where More generally, there are lots of reasonable patterns for triggering an async update based on interaction with a component and then updating the component when the async work is done; Lit tends not to be overly prescriptive about things like this. Reactive controllers in general, and the Task controller in Lit Labs specifically, are likely to be useful in more complicated cases. BTW, although I wouldn't suggest using the Lit reactive lifecycle for your use case, the |
Beta Was this translation helpful? Give feedback.
-
Hello,
Also related to #2151
For me it's not completely clear how to use the Lit element lifecycle in some use cases.
For example:
https://lit.dev/playground/#gist=4de71cf093a94f841b8aefa9db8c27c1
contains an example of a property "asyncPropB" that depends on some property "a":
So my questions are:
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions