Let's Make A Todo App Using Svelte 5 Runes

Поділитися
Вставка
  • Опубліковано 17 січ 2025

КОМЕНТАРІ • 117

  • @JoyofCodeDev
    @JoyofCodeDev  Рік тому +89

    I definitely didn't forget to include how to remove a todo and did it on purpose to give you homework.

    • @jakobsturm2438
      @jakobsturm2438 Рік тому

      Thank you!

    • @parkourbee2
      @parkourbee2 Рік тому +5

      Lol it's not a bug, it's a (lack of) feature!

    • @sharkw9682
      @sharkw9682 10 місяців тому

      Thanks for this video! I think I've found a subtle bug playing around with the todo app in Sveltelab. If you add several todos, then check off a few of them, then use the active or completed filter, and then try to edit or toggle a todo, the wrong todo will have changed when you go back to the all filter. This is because the index of the filtered todo which is being edited or toggled does not correspond to the index in the unfiltered todo list. There's a few ways to fix this which would be a good exercise as well!

  • @zkoolkyle1
    @zkoolkyle1 Рік тому +6

    Hey Joy of Code! Big fan. Keep up the great work and excited to see more Svelte 5 stuff.

  • @Gabriel-ch7sx
    @Gabriel-ch7sx Рік тому +5

    Thank you! Every time I watch one of your videos I learn more than I expected. This time it was switch statements and how to generate UUIDs and also I understood better how to use Svelte class directive. Please continue making these videos, they make the life of newbies like me easier!

  • @sistana
    @sistana Рік тому +4

    And how beautiful this is, friend!!!

  • @SRG-Learn-Code
    @SRG-Learn-Code Рік тому +1

    I love the amount of things I learn from your videos besides the main topic.

  •  Рік тому +1

    Amazing work like always, thanks for the quick videos on svelte 5

  • @omercelebi2012
    @omercelebi2012 Рік тому

    It was my first Svelte project and very fun!

  • @zolkimariko9433
    @zolkimariko9433 Рік тому +1

    Very very cooool svelte 5 with new syntax state. I like it... Thank you

  • @nomadshiba
    @nomadshiba Рік тому

    i have some issues with ts and css choices in the video
    but it explains svelte runes, so good

  • @flwi
    @flwi 8 місяців тому

    Very nice tutorial, well done!

  • @justingolden21
    @justingolden21 Рік тому +4

    10:00 I think the reason you like it (and that was my gut reaction too) is that it's cleaner. It's cleaner because it's 1) more consistent and 2) keeps the js logic out of the html and has each thing in their own section

    • @JoyofCodeDev
      @JoyofCodeDev  Рік тому +3

      You also can't use TypeScript in the template yet.

  • @ronykax
    @ronykax Рік тому

    You’re amazing man keep going!

  • @JoseDv1
    @JoseDv1 Рік тому +4

    How could we refactor this code to separate the component logic to a new file? Are runes available outside svelte components?

    • @JoyofCodeDev
      @JoyofCodeDev  Рік тому +4

      You can use runes outside Svelte components like stores. For that you're going to have a `.svelte.ts` file, so it can be optimized by the compiler. I don't know if that's working yet.

    • @mwlulud2995
      @mwlulud2995 7 місяців тому

      ​@@JoyofCodeDev He not work in my side

  • @registro_pedagogico
    @registro_pedagogico Рік тому +3

    Muchas gracias y a seguir adelante mi estimado

  • @justingolden21
    @justingolden21 Рік тому +1

    14:20 getting into runes

  • @BRODZELi
    @BRODZELi Рік тому +1

    Thanks for sharing.

  • @jondoe79
    @jondoe79 Рік тому +1

    You can use css grid to align items to start, center, end.

  • @ScriptRaccoon
    @ScriptRaccoon Рік тому +2

    I am very confused. I was assuming that frameworks like Svelte and Vue (not React for sure) allowed us to remove the event.target.value boilerplate code from our event handlers, namely by using bindings. Is this feature gone in Svelte 5 or what is the reason the bindings didn't appear in the video?
    Also, what is the advantage of using Svelte 5 in this specific Todo app? The video didn't explain this. I can achieve exactly the same with Svelte 3 and less code.
    In the end, it is claimed that the code is much easier to reason about - why?

    • @JoyofCodeDev
      @JoyofCodeDev  Рік тому

      You can runify the todo for fine-grained reactivity and use the `bind:` directive.

  • @Jake-bh1hm
    @Jake-bh1hm 9 місяців тому

    wow.. i love svelte.

  • @h_i_g_s_c_h_videos
    @h_i_g_s_c_h_videos 11 місяців тому

    Thank you for this video! Is it also possible to bind the checked attribute to the done property in your todos array? Like: bind:checked…

  • @chanandlerbong6176
    @chanandlerbong6176 Рік тому +2

    Using index for edit todo is a bug after introducing a derived state

    • @vavhust
      @vavhust Рік тому

      Yes, it should be using some sort of ID of todo or it might be index of filteredTodos

  • @xthesly
    @xthesly Рік тому

    Very nice ! 👍

  • @coder_one
    @coder_one Рік тому

    Are there any reliable leaks on when to expect the Svelte version 5 at the latest?

  • @tomm5765
    @tomm5765 Рік тому

    Beautiful tutorial. Little surprised you didn't demonstrate fine grained reactivity using runes for the todo values. So that values can be updated without reassigning the list. That's the best feature of runes imo.

    • @JoyofCodeDev
      @JoyofCodeDev  Рік тому +1

      The reason I didn't runify the todo is because you would have to runify the todos again from local storage which is more advanced and it would sour people on runes because it's not ergonomic until Svelte comes up with a primitive to make it easier.

    • @dave-7117
      @dave-7117 Рік тому +1

      Classes

  • @BhideSvelte
    @BhideSvelte Рік тому

    🎉🎉🎉🎉 i just love it

  • @labdo_
    @labdo_ Рік тому

    21:40 How does the remaining function update each time todos are changed?

    • @tomm5765
      @tomm5765 Рік тому +1

      Good question, I had to double check this is in my code.
      `{remaining()} remaining` since the `remaining` function is used in the template then the its re-evaluated when its dependencies changes. Since `remaining` has dependency on `todos` when `todos` is changed then `remaining` is updated.
      I originally thought it was necessary to use a derived. Matia uses a derived `filteredTodos` but he could have also just used the function in the each `{#each filterTodos() as todo, index}`

  • @sebastianscarano9418
    @sebastianscarano9418 Рік тому +1

    I thought that signals could track changes to reactive data however they were made, but the fact that we still need to assign a value to trigger reactivity (meaning just a todos.push(...) won't work) makes me think that it's still the compiler the one triggering the reactive update
    am I wrong?

    • @tomm5765
      @tomm5765 Рік тому

      Signals wrap a value with a getter and setter, the getter is used to track users of a value, the setter is used to track when to update users. "Reactivity" occurs when the setter is called and all the getters are called with the new value. If an object or array is just mutated and not re-assigned then the setter is never called. Actually, tracking mutations is something the compiler could have improved upon over signals, I am not sure why they haven't, maybe because its hard to track exactly every type of mutation.

  • @sylensdrake9706
    @sylensdrake9706 Рік тому +1

    why edit function? why not bind: ?

    • @JoyofCodeDev
      @JoyofCodeDev  Рік тому +1

      That only works if you runify the todo.

  • @icemelt7ful
    @icemelt7ful 3 місяці тому

    This is really a step back from react
    To find which effect runs on mount you have to read the code, in react you can just peek at the dependancy array
    You didn't derive remaining but derived filter todos, why?

  • @sebastianscarano9418
    @sebastianscarano9418 6 місяців тому

    do you have a repo for the project? I can't get it to work on sveltelab, and just installing open-props from npm didn't seem to work

  • @wtfenc0reenix
    @wtfenc0reenix 10 місяців тому

    nice video, but when i try to put the function filterTodos like in the video i get a error: cannot acces filterTodos before initialization. is there something what got changed in the last month?

  • @federicodifrancesco1248
    @federicodifrancesco1248 Рік тому

    Congrats and thanks Matia! Just one stupid question: which color theme do you use in your vscode? 😅

    • @JoyofCodeDev
      @JoyofCodeDev  Рік тому

      You can find what I use in the description.

  • @icemelt7ful
    @icemelt7ful 3 місяці тому

    why didn't you mark remaining as a derived value?

  • @markvu7652
    @markvu7652 Рік тому

    what font are you using?

  • @daniel-nagy
    @daniel-nagy Рік тому

    Ne znam što se dogodilo s mojim komentarom pa ću pokušati ponovo (c/p).
    Odličan kao i uvijek! 👏
    Pratim tvoj kanal i pogledam skoro svaki video iako uopće ne koristim Svelte u svom radnom okruženju.
    Jedan mali savjet oko stiliziranja inputa odnosno preklapanja elemenata unutar nekog kontejnera za koji si koristio "old school" trik s position: relative/absolute. Za isti efekt možeš iskoristiti display: grid na kontejner elementu te grid-area na elementima unutar njega. Znam da nisam sada apsolutno ništa objasnio no bit će ti jasnije kada pročitaš kratak članak autora Stefan Judis naslova "CSS Grid can be used to stack elements" u kojem možeš naći i odličan video koji vizualno objašnjava korake potrebne za željeni efekt.
    Živio!

  • @alexanderleschanz9991
    @alexanderleschanz9991 Рік тому

    wow! very impressive!

  • @philla20
    @philla20 Рік тому

    Nice stuff, as always!
    Can you explain why the first effect block only runs on mount?
    Is it because todos gets assigned and isn't on the right side? First thought was that both effect blocks get run each time todos gets updated.

  • @seunghwanjeong5348
    @seunghwanjeong5348 Рік тому

    I really like your videos teaching me good lessons. Thank you for hard working😁
    There is one question I want to ask.
    is there a reason that you don't use getter and setter with todo in todos?

    • @JoyofCodeDev
      @JoyofCodeDev  Рік тому +2

      I didn't runify the todo because you would have to runify the todos again from local storage and I'd rather wait to see how Svelte solves this problem instead of confusing people.

  • @khawarizmyana
    @khawarizmyana Рік тому +1

    Thanks! but i miss the simplicity of the old svelte 😿

  • @gebreeze
    @gebreeze Рік тому

    Why no usage of databinding?

  • @parkourbee2
    @parkourbee2 Рік тому

    Wow, Svelte just got a lot easier!

  • @hamzamuric
    @hamzamuric Рік тому

    What font is this?

  • @MM-24
    @MM-24 Рік тому

    Great video, where are the styles coming from?
    I know we are skipping over it, but it def looks nice, is it a framework?

    • @JoyofCodeDev
      @JoyofCodeDev  Рік тому +1

      I use Open Props and the styles come from `+layout.svelte` if you look at the example in the description.

  • @AbhinavKulshreshtha
    @AbhinavKulshreshtha 7 місяців тому

    You installed svelte@next, but what was installed was a sveltekit project !! 😕

  • @aquapaka
    @aquapaka 10 місяців тому

    Using data-index={i} and filtered produce a bug where checking an item in 'active' or 'completed' filter make it update wrong item.

    • @aquapaka
      @aquapaka 10 місяців тому

      Edit have that bug too. I think using bind is much more simpler, no toggle, edit boilerplate functions and don't produce those bugs.

  • @Edgar-pu1lc
    @Edgar-pu1lc Рік тому

    Hi, I want to switch from react to svelte, do you have courses?

    • @JoyofCodeDev
      @JoyofCodeDev  Рік тому

      I have a Svelte and SvelteKit playlist.

  • @Animadroids
    @Animadroids 8 місяців тому

    when i download latest, i still get "svelte": "^4.2.15"

    • @JoyofCodeDev
      @JoyofCodeDev  8 місяців тому

      It's not latest, it's `svelte@next`.

    • @Animadroids
      @Animadroids 8 місяців тому

      @@JoyofCodeDev thanks

    • @Animadroids
      @Animadroids 8 місяців тому

      I am facing an issue implementing routing. I get 404 not found with href and javascript error(Uncaught Error: Invalid status code) when i use redirect. Any suggestions how to tackle this in svelte 5 ?

  • @matthewcole4521
    @matthewcole4521 Рік тому

    can we now do () => {} inside of $derived ?

    • @JoyofCodeDev
      @JoyofCodeDev  Рік тому

      I thought you could but it seems you have to invoke it.

  • @xx__xx7199
    @xx__xx7199 Рік тому

    🎉🔥🚀

  • @metalllus
    @metalllus Рік тому

    something must have changed between next 4 and current next 22 because now the filtering is not working reliably if at least one todo is marked as completed

  • @vtoscano
    @vtoscano Рік тому

    Bienvenidos a USA, desde Mexico

  • @bn5055
    @bn5055 Рік тому +1

    "We still use reassignment in Svelte 5"... isn't the new reactivity system supposed to do away with that? 🤔

    • @JoyofCodeDev
      @JoyofCodeDev  Рік тому

      You would have to use something like `setState`.

  • @ukaszzbrozek6470
    @ukaszzbrozek6470 Рік тому +1

    It became closer to Vue and React. That isn’t a bad thing.

    • @ozgurNY
      @ozgurNY 6 місяців тому +1

      Svelte 5 syntax gives me heartache. It is so sad they runed Svelte. It was a joy learning Svelte 4.

    • @ukaszzbrozek6470
      @ukaszzbrozek6470 6 місяців тому

      ​@@ozgurNYit is necessary. They took all of the complexity on themselfs.

  • @ariel_chess
    @ariel_chess 5 місяців тому

    KDE mouse but GTK themed browser... Interesting, I wonder what's going on

  • @Danielo515
    @Danielo515 Рік тому

    Being specific on the function parameters is not pedantic, is common sense

  • @pookiepats
    @pookiepats 5 місяців тому

    Svelte 5: Because Svelte 4 was too easy 🙃

    • @JoyofCodeDev
      @JoyofCodeDev  5 місяців тому +1

      you're emotionally attached to a JavaScript framework

  • @JaLikon65
    @JaLikon65 Рік тому +1

    Challenge: this guy makes a bad video
    Challenge Level: *literally fucking impossible*

  • @heugh_jazz
    @heugh_jazz Рік тому +1

    man you're a svelte god but please don't take shortcuts by using stuff like bang as you are sometimes exposing first timers to svelte.
    i know it's not a typescript tutorial but a minute to do something the right way will go a long way.

  • @hansiboy5348
    @hansiboy5348 Рік тому +1

    Why even use typescript if we are ignoring it's features by having so much type casting and type assertion? Would JavaScript with jsdocs not be more suitable?

  • @davidjesus8629
    @davidjesus8629 Рік тому +1

    I used to be all for Svelte but, since runes were announced, everything seems to have a gotcha, a more verbose way to do stuff that has already been solved elsewhere simpler or something just weird for the sake of "future less headache" so i am not sure anymore

    • @The6DAZ6
      @The6DAZ6 Рік тому

      I think exactly the same, Svelte lost it's true killing feature: simplicity

    • @phene-449
      @phene-449 Рік тому

      @@The6DAZ6 not sure why exactly you think it's not simple. it's easier with runes than it was before.

    • @davidjesus8629
      @davidjesus8629 Рік тому

      @@phene-449 So replacing stores makes up for the rest of the "oh well this doesnt quite wok like every other signal implementation, you need to workaround it with x"?. The point of runes was to bring state powers to every scope posible, but we have to use verbose javascript to do so, Rich as great as he is, proposes Classes, this is not a fix, is just that it turns out that classes are LESS verbose than returning a simple function. What even is the appeal of Svelte if i need to keep in mind this lot of gotchas just because they are ALL IN on this mental model. Vue, Qwik, Solid and NOW even Angular already solved signals in a more elegant way, even if with larger scale projects they maybe harder to scale, complicating things with gotchas everywhere is just a headache to begin with. People that dont use React run from it exactly because it has so many framework especific funcionality that they just go crazy, and now, just because maybe when my codebase is that of one BIG app, i may avoid a few lines and more debuggeable at the cost of everything being more verbose? Sorry but no, Svelte is not svelte-like anymore.

    • @tomm5765
      @tomm5765 Рік тому

      ​@@davidjesus8629 I look at runes as a reactive primitive that replaces both `let` based reactivity and stores, and its more consistent for those two use cases. Yes there is a big gotcha with runes not leaving scope, so requiring get/set or classes, but that is a single gotcha compared to the many gotchas of `let` reactivity and stores.

    • @tomm5765
      @tomm5765 Рік тому

      Runes are more svelte-like that other signals implementation, they act the same way as `let` reactive variables. Imagine the uproar if svelte was changed to use `.value` or function calling to access the signal instead.

  • @SRG-Learn-Code
    @SRG-Learn-Code Рік тому

    I think people is scared of Rich removing stores or simple reactivity, but in the end is just another tool that you can use when you find yourself against an apparent easy but really hard problem.

    • @AlanDanielx
      @AlanDanielx Рік тому

      Rich, isnt going to delete regular stores, nor we think that

  • @SamBritt-c9j
    @SamBritt-c9j Рік тому

    Vue much?

  • @AlanDanielx
    @AlanDanielx Рік тому +1

    I Always Give good rating but This Time My Friend You Focused A Lot On css….👎🏻

  • @tobiasparent4806
    @tobiasparent4806 Рік тому

    A very small nit, regarding your `remaining()` - this could have also been set as a `$derived()`, thus becoming an observable as well.
    `let remaining = $derived(todos.filter(({data:{done}})=>!done).length);` and, in your markup, `{remaining}`
    Great intro to runes, and really eye-opening. Thank you for this!

    • @JoyofCodeDev
      @JoyofCodeDev  Рік тому +1

      Yeah! 😄

    • @tobiasparent4806
      @tobiasparent4806 Рік тому

      @@JoyofCodeDev just realized my filter in there is horribly obfuscated, sorry about that lol