Replies: 1 comment
-
Hi,
Is good because occurs early in lifecycle so the first render can reflect the fetch state (loading, success, error) as opposed to using One of the caveats is that Should be considered also if the data to be fetched depends on the value of a property to be used, e.g., as an param in an remote endpoint. Some thing like a To have a flexible component, some situations must be handled: personId is set at instantiation time, personId is NOT set at instantiation time (undefined in I tried to fetch both in I'm still using lit-element v2. The v3 added new lifecycle that may fit better in this situation. Regarding the question itself those are my thoughts. Generalizing a bit, in the process of improving the architecture of my projects, i'm trying to avoid fetch data in the component itself to simplify element implementation. I use a kind of controller responsible to track routing changes, connect to services and stores (app data). This controller pass fetched data to element and listen to element events to eventually fetch or update data. The element gets simpler and easier to be tested / demoed. Also the data is fetched earlier improving responsiveness |
Beta Was this translation helpful? Give feedback.
-
I've read it could be in the constructor or on
connectedCallback
, is one better the other?Beta Was this translation helpful? Give feedback.
All reactions