Avoid Async Effects In Svelte

  Рет қаралды 5,933

Joy of Code

Joy of Code

Күн бұрын

Пікірлер: 47
@hex7557
@hex7557 Ай бұрын
Thanks so much! I've been working on an application that uses Svelte 5 and accesses a database, and finding any information on how to handle things asynchronously has been a nightmare.
@DeviantFox
@DeviantFox Ай бұрын
I was not expecting THIS much depth in this short of a video lol
@huakun
@huakun Ай бұрын
what if the returned cleanup function depends on the async function? e.g. the async function returns an unlistener. The solution I can think of is to store the unlistener outside as a mutable variable with let, then call it in the clean up function.
@JoyofCodeDev
@JoyofCodeDev Ай бұрын
sounds good to me
@huakun
@huakun Ай бұрын
the use of unlisten is very common in Tauri apps. I use onMount and onDestroy, hope they don’t get removed
@davidpierrumentor
@davidpierrumentor Ай бұрын
Hi, I love your video and I the feeling you put in it. May I suggest a video on testing a simple application with svete and vitest ? (without and with sveltekit ?). I didn't found any great video with svelte 5.
@honk_tm
@honk_tm Ай бұрын
So we are back to writing vars without any other purpose than forcing a refresh on an effect, just as we had with $: before. I thought Svelte 5 was made to fix that horrendous thing...
@JoyofCodeDev
@JoyofCodeDev Ай бұрын
you should avoid effects and `$:` was used for both deriving values and side effects but now you have `$derived` and `$effect`
Ай бұрын
I think the "solution" at 355s (5:55) has the same issue, that count is not tracked.
@dumboluzz
@dumboluzz Ай бұрын
I was thinking the same. Gotta try this out once I get home
Ай бұрын
@dumboluzz I did already 😉
Ай бұрын
btw I think the solution is to pass count into the async function as parameter
@JoyofCodeDev
@JoyofCodeDev Ай бұрын
you can move `count` before `await` otherwise Svelte won't track it
Ай бұрын
@@JoyofCodeDev sure, but in real cases probably you want to use the value inside the async function. so passing as parameter can be seen as "moving above async"
@mylastore
@mylastore Ай бұрын
Don't you need await to fulfill the promise/async ?
@j.m.manhard
@j.m.manhard Ай бұрын
First 🎉
@StephanHoyer
@StephanHoyer Ай бұрын
Or even better, just avoid svelte
@realderek
@realderek Ай бұрын
If you don't like Svelte why waste your time watching and commenting on Svelte videos?
@aramp
@aramp Ай бұрын
if you think front-end frameworks are useless you probably haven't worked on anything complex
@oskarkottom8365
@oskarkottom8365 Ай бұрын
Says the react user
@StephanHoyer
@StephanHoyer Ай бұрын
Yes I don't like because it's such a dumb idea and I don't understand why anyone thinks it is a good one. Sure, for anything simple it might be worth it. But for complex apps the framework part is only a fraction of the resulting code so why not using a real framework in the first place. And one which actually works like javascript not some complex custom language that relies on magic left and right and that isn't debuggable at all. And no I don't hate frameworks. I use a really great one called mithril that is simple yet powerful and small. And I also build a pretty complex app with it the is comparable to Google docs or canva. And it works like a charm for years now.
@StephanHoyer
@StephanHoyer Ай бұрын
@realderek I generally also watch videos about other frameworks to learn something that I can use in my framework of choice. May there are some good ideas there too
@RohitKumarAnkam
@RohitKumarAnkam Ай бұрын
Hi everyone, kzbin.info/www/bejne/nIOZdXmBppZmgJI what rich is talking about here?
@JoyofCodeDev
@JoyofCodeDev Ай бұрын
I think Rich is talking about suspense and fetching data at the component level like RSC, which Svelte right now doesn't support, but they're thinking about it
Master The Svelte Context API
18:07
Joy of Code
Рет қаралды 9 М.
20 Svelte Features You Missed During Advent Of Svelte
20:07
Joy of Code
Рет қаралды 11 М.
Wednesday VS Enid: Who is The Best Mommy? #shorts
0:14
Troom Oki Toki
Рет қаралды 50 МЛН
Easy Auth, Database, i18n Setup And More For SvelteKit
12:21
Joy of Code
Рет қаралды 10 М.
Crafting Magical Spells Using Svelte's Powerful Reactivity
13:53
Joy of Code
Рет қаралды 13 М.
Svelte 5's Secret Weapon: Classes + Context
18:14
Huntabyte
Рет қаралды 32 М.
5 deadly Rust anti-patterns to avoid
13:25
Let's Get Rusty
Рет қаралды 38 М.
Stop using std::vector wrong
23:14
The Cherno
Рет қаралды 165 М.
When To Use Page Versus Standalone Endpoints In SvelteKit
18:45
Joy of Code
Рет қаралды 9 М.
Arenas, strings and Scuffed Templates in C
12:28
VoxelRifts
Рет қаралды 100 М.