3 ms·
Is it common practice to put main thread blocking async await Fetch requests in UI components in Svelte? That's a very bad idea. The user can't so anything else
by onion2k 6y ago
Is it common practice to put main thread blocking async await Fetch requests in UI components in Svelte? That's a very bad idea. The user can't so anything else in the app until that request completes. If they're on a slow mobile connection the UX is going to be pretty horrible, especially as the component doesn't give the user any feedback that something is happening or any option to cancel.
- PaulBGD_ 6y agoTo start off, putting an async function there just means the promise will be executed somewhere, not that the UI thread will stop. Svelte does not wait for promises in events on elements. As well in a full application, Svelte actually has an {#await} syntax that allows you to wait on a promise. I personally would then have a variable representing the currently waiting promise, then use await to show the status/error of the promise.