Don't Sleep on Svelte 5

Поділитися
Вставка
  • Опубліковано 20 вер 2024
  • I think the changes introduced in Svelte 5 are great, and in this video, we'll build out the same feature once using stores, and again using signals in Svelte 5 to showcase how much better Svelte 5 makes composition.
    REPL: hbyt.us/signal...
    Joy of Code's Svelte 5 Runes Introduction:
    • Svelte Runes Change Ho...
    (tell him he'll be hearing from my lawyers about the thumbnail copyright 😉)
    🚀 Modern SaaS Course: hbyt.us/modern...
    💬 Discord: hbyt.us/discord
    🐦 Twitter: hbyt.us/twitter
    🖥️ Setup Stuff: hbyt.us/gear
    📃 Topics Covered:
    - Svelte stores
    - Svelte writable
    - Svelte custom store
    - Svelte 5 runes
    - Svelte signals
    - Svelte 5 composition
    - Svelte 5 state
    - Svelte 5 reactivity
    - Stores vs Runes
    - Svelte 5 stores
    - Svelte 5 performance
    - Svelte 5 examples

КОМЕНТАРІ • 140

  • @SoreBrain
    @SoreBrain Рік тому +66

    Runes even in their primitive form seem to add so much value. Great insights, thank you!

    • @Huntabyte
      @Huntabyte  Рік тому +7

      I agree, it's super cool to see the things people have been creating with them, like Solid's createSignal, Vue's ref, etc!

  • @jerebenitez8542
    @jerebenitez8542 Рік тому +22

    People disliking runes because of the API is dumb IMO. They just saw the word "state" and "effect" and got scared, but didn't stop to think about the performance and readability improvements that are possible with this. I think it's the right move, and this video shows one very clear reason why

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

      Mostly people still in todo app phase from freecodecamp, nothing to be worried about

  • @felipericardi6019
    @felipericardi6019 Рік тому +46

    Lovely how natural runes are looking now. For me, the most important is that you write it very similar to the thought process (at least mine lol). On React i feel that the code gets all around the place so quick. Svelte has been a breath of fresh air :D

    • @Huntabyte
      @Huntabyte  Рік тому +13

      Totally! It'll become second nature for everyone after using it for a bit! I actually tried typing $state() in a Svelte 4 codebase this morning 😂

  • @yusafme
    @yusafme Рік тому +27

    OK. now that was a CLEAN explanation, natural teacher 👨‍🏫 Thanks!

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

      Thank you! I'm glad you received it well!

  • @WyzrdCat
    @WyzrdCat Рік тому +14

    As someone who is learning Svelte now I definitely think the new way is more intuitive

  • @Venyl
    @Venyl Рік тому +13

    I would definitely appreciate if you did a deeper dive on runes, because even with this I was completely clueless about how the $state rune can simplify logic that you showcased

  • @hglbrg
    @hglbrg Рік тому +12

    I think this was a great example to quiet all those memelords going "Svelte is becoming React" as a response to the latest announcement. You clearly show it is very much still Svelte minimalism/simplification even when introducing things from react frameworks and libs.

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

      Mostly people still in todo app phase from freecodecamp, nothing to be worried about

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

    Would love a deeper dive. This is honestly not sinking in yet, but as soon as you showed the last example I realised how clean some of my code could become. Intriguing.

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

    Signals in Svelte look so smooth and elegant. This is a great step ahead, cool!

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

    I’m excited about signals! Huge change and improvement

  • @AB-gx5zj
    @AB-gx5zj 8 місяців тому +2

    Nice demo, thx!

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

    This was a well structured and informative video. Best runes video so far

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

    That is a good explanation! Thank you. You get me excited about Runes

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

    Thanks for the explanation. I guess it will take a while to get used to this new system of reactivity. Mixed feelings tbh.

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

      That's another great thing about the update is that you plenty of time to get used to it with the backwards compatibility! And stores aren't going away, you just may not reach for them as often when the same can be accomplished with better performance and cleaner composability!

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

      @@Huntabyte yes, I like that. :) One big drawback of these kind of smooth transitions, though, is that a large codebase (I work in a project with literally thousands of Svelte components) will have both versions, and the transition will probably never be complete. This can produce mental overhead. Which system should I use in this component? And this can also get quite tricky for beginners. To be honest, I would have preferred to make it NOT backwards compatible.

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

      @@ScriptRaccoon So I was actually trying to find a place where migrating to 5 in one place breaks something using just 4 and I seriously couldn't produce an example, so it appears they have the ground covered well. Otherwise, I'd agree with you 100%, but I do see the _why_, especially considering the amount of potential changes (this is just the first preview of Svelte 5!)

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

    Great video dude! 🤙

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

    i just liked your video, bcz everything you said is gold!

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

    Killer video! I actually thought of your video from the other day and took that as a refactor experiment this morning.

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

      I knew this change was coming and wanted to have that out as an example to point this video to (as well as for use until 5 is released of course)!

  • @benitocanfora9574
    @benitocanfora9574 10 місяців тому +1

    Hi man, could you indicate me the resources on how is intended to capture the press of the cancel and action button in the shadcn-svelte alert dialog? Thanks for your work!!

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

    As always; excellent content! I think it will become more obvious when using an object with a few values that need reactivity as you can individually re render those values with signals instead of renewing the whole object every time a value changes with stores. Great for SPA development for instance or the use of state machines. Maybe a nice video for beginners in Svelte?

  • @nelhoa
    @nelhoa 4 місяці тому

    Thanks ! Nice video
    I would love to add one thing that is very hard to do today with svelte 4, and will be completly natural with svelte 5.
    If you use OOP (Class and stuff) you may need to have items with stores inside for managing reactivity. Like, for exemple, class Todo, could have a 'done' property set to writable(false).
    And then you might want a store to manage all your todos. Like todos = writable([]).
    You may often need to filter your todos based on their 'done' state. But look how crap it is :
    If you do $todos.filter(todo => get(todo.done)), this will work once, but if one of the todo 'done' property changes, it won’t be reactive since todos won't be reassigned.
    One thing you can do, but it's ugly, is, every time you update 'done', notify todos like todos.update(i => i). OK.
    But now imagine that you have nested Items list in your items list with store properties and you want to filter at the root… its starts to get impossible to manage. For exemple, you have a Label class, with an 'active' writable todo.labels.filter(label => label.active).length === 0)))
    And it works !!!
    Try it out svelte-5-preview.vercel.app/#H4sIAAAAAAAACnWTTZObMAyG_4pLM2OYYUnaYwrZ9rCdHtpbbyEHLxaJp8ZmbJFuhuG_d2RDNvvR4WLpkaxXQh6TVmnwyXY_JkZ0kGyTb32f5AleejL8GTRCkifeDq4hT-kbp3rc1aY2NTZaeM9-ikfQbCRHjaJBdQZWsZVHgZCiGyAjNM0p1nhkIPyFVczA35idZs_sJJz8H-vUW3TV8dtKu8jQhP2zjP1hDp1vckOD1qUxLJuTlrT7orXuQTSnyFm1Y3hSvoi06Ac_kyyLidObBtFKe1s-xpFwUpnuaQCHLH_tpt7fcXdKBv24dHFT5LvSCA5oLisJTp1BpjE_4KINPF06JGdoyEq7NDSHXJsNhyL-yazQYI54YlVVsU28JUjJvgTD1LhSxvfQYPpCT1Barm_2Zfzojep7wFggpY3LmULosjDA8nFAtIZZ02jV_KnGNCM1FFBc1-rDjTnt5tWjmyY23kbeM648iwZn22DZtuVTuY5ldrUZ17Og8OtKqc7M40XDthPuqEzFN2zDPn3un9iGz0Qq32txqXir4Wlx0vlOKgcNKmsq3lg9dGahQqujuSNtvuINGAS3oKPoK04FOKn56sBIcPN0-IPwF56Hp0LzeY1_KclzehDvwR_CEaV1IlyupTrHNxu-JE86K1WrQCZbeqHTYfoHvYkkSAwEAAA=

  • @erickmoya1401
    @erickmoya1401 Рік тому +12

    Svelte stays simple. Before it was simple magic, now its more like simple obvious. And to be even more relevant, it is obvious for new joiners.
    I understand some hate to signals, but after developing a whole component library I see the use for these. My current notification toast and modal would be much easier with signals.
    Svelte is the only UI framework that seems to evolve instead of just adding more stuff, like React and others. Weights less, is faster, is simpler. I bet on it.

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

    Thanks for the video. As a newcomer to Svelte (and frontend in general, really), I have a hard time wrapping my head around the store approach. The approach that Svelte 5 offers seems way simpler.

  • @HemalRuparelia1
    @HemalRuparelia1 10 днів тому

    I think the svelte 5 store, as per the video, if used directly in multiple components will initialise a new store each time it's used. If that is not the desired intent, I think you can initialise the store once at the bottom of the file and export that initialised store instead. (I'm assuming there's no issue doing it that way with SSR)

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

    it drives me crazy repl doesn't support typescript... 😢 Great video!

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

      Was just talking about that yesterday after looking at the Solid playground 🫠 hopefully soon!

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

      Because it's not Typescript, it's SvelteScript :) they need to rewrite their language server to support new syntax

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

      @@JLarky - Considering Svelte is sort of its own language with a compiler, why not just make it have its own types too... would be interesting... no ts, no js, ss for sveltescript lol, sort of

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

      ​@@jonathangambleYep, that is actually a great idea.

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

    Awesome! I'll dive deep into runes/siginals

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

    One minor gripe with the code you ended up with: that curr setter isn't very intuitive; I'd replace it by a method named "save".

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

    I live under a rock.

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

    Oh this is nice, it works similar to pinia setup stores

  • @nooalovern
    @nooalovern Рік тому +9

    Finally some actual content about runes instead of everybody crying over linguistics and making piss poor comparisons to X/Y framework. As a software engineer, I feel like software engineers are the most miserable people in the universe.

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

      No lies were spoken in your comment 😂

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

      Agreed! Been coding nearly 30 years, never a truer word said

  • @diego.almeida
    @diego.almeida Рік тому +1

    Great video as always! Are you guys planning on updating Melt-ui to use signals as well?

  • @adilwebdev1387
    @adilwebdev1387 10 місяців тому +1

    im new to svelte i came from react and i love the new runes update

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

    Another thanks for the explanation!

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

    For a newbie like me, what are the benefits of Svelte now compared to React or Vue, for example? The first time I saw Svelte I fell in love with its simplicity, now I don't see how its advantages over Vuejs, for example. Now Vue looks more simple to me. All my excitement to learn Svelte has completely gone.

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

      It’s even simpler than it was before. They’re able to eventually drop a ton of API surface with a few runes! Additionally, it makes building libraries and more complex apps better as well!

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

    Nice video. Very clear

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

    Seems like a Derived store would've been far simpler than implementing custom logic into the writable set

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

      Can you provide an example REPL? Curious to see, as when I tried using derived it became a mess because derived is updated after something changes, not before and doesn't include the current / next values.

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

    Nice explanation. Thanks!

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

    Maybe a stupid question but how would you unit test a function that involves runes $ syntax (eg withPrev.js here)? Needing to render a component in order to test the function seems a bit hacky, and the js wouldnt run without being compiled

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

      Do you use vitest? Should work fine

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

      @@tom400iq6ft I’m not following, using $state in a JavaScript file throws an error, would vitest compile it? (When this is released)

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

    Lovely vid , cant wait till it gets released

  • @1DJRikkiBee
    @1DJRikkiBee 9 місяців тому

    I definitely enjoy the simplicity of Svelte 3, but I certain see the importance of having a more explicit API especially for use in pure js files

  • @mylastore
    @mylastore 4 місяці тому

    So, Stores now become what? Runes? Signals? What is the official name. I am so confuse of what is Runes, what is Signals.

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

    The changes lower required mental effort. Just make every value you want to make reactive a $state rune, and that's it. Way simpler than before.

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

      Exactly. In every file, which is incredible!

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

    I am really excited for the changes but have a few worries.
    Yes, the new system is super powerful if you use stores the way you showed, but in reality, I use stores in entirely different way. For me they are a global bucket for the whole application, which I know I always can access and for safety I can implement a few functions around these stores, but I have never done them in the way you showed in this video.
    This new store system feels more like redux toolkit, which is actually really good, but I got so used to these svelte stores, because they just clicked with me and I feel like I can't use them in any other framework, but now I won't be able to use them at all it seems.
    Anyway, I'm really excited about the changes, the old system was really good for simple solutions, but for more complex ones it could become a bit of a mess, I'm sure the Svelte team though about things like that and I will trust their decisions.

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

      They will provide helpers to easily make something like a ‘writable’, so if you aren’t writing custom stores today you will not even see the internals, but still get the performance boosts

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

    Thank goodness, it's finally making some sense. I've watched a handful of "introduction to runes" videos, and it just didn't click for me. I've only made a single web project in my life, and I did not need stores for it, so to me runes seemed to complicate syntax as opposed to simplify.
    I have some new functionality planned that will need stores, so I'm crossing fingers this will get released before I'm forced to implement that. It would suck to have to learn stores such a short time before runes make them obsolete.

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

    That's the thing with this runes, they are signals -> you can do signal without svelte. I hope next feature before svelte 5 release are islands.

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

    Great stuff! Thank you… how about a more complex example using objects please. Would we still need to do $someStore = $someStore to trigger reactions to a list being modified for example?

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

    Very well explained. After watching your video, it occurred to me that what runes are trying to accomplish this fine grained reactivity where the variable can carry their own reactive state instead of relying on an external component such as store to do it or using any special compiler magic which can do this only for svelte file with special $ prefix syntax. This is a really powerful concept. Your video makes this amply clear. Kudos to the svelte team for recognizing the pain of coerce grained reactivity which ironically when it was introduced was one of their selling point over react. Also the fact that they are making transition so smooth is amazing.
    I used to love store for its contractual flexibility which made it possible to use external libraries such as xstate and rxjs to be used as store. I am wondering if you have any thoughts on how it can be accomplished using runes. Would a simple wrapper function work?

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

      Yeah! There’s been a few examples in the runes channel in the svelte discord already. If you need start/stop notifiers then you can of course stick to stores for things like that, as they’re still a first class citizen, you just won’t reach for them _as_ often in Svelte 5!

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

    I've already complain about how stores work different in Svelte files and JS/TS files (even in context module they are different), it is good to have only one way to use things, I have to be honest, "state", "effect", these names are weird in Svelte world, they remaind me React, but at least you have not getters and setters for each state like in React, and you don't have to use state.value or state.current like in Vue, the getters and setter in this video are only due to function boundaries, this is great, a $state is only a thing to tell the compiler what to do, but its usage still the same.

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

    That’s a new one for me. Same syntax, different result:
    let curr = $state(initialValue);
    curr = prev;
    First line gives a variable ‘curr’ a new value. Second line doesn’t give a new value to the variable ‘curr’ but does something to the state of the current value of ‘curr’. Confusing to have the same syntax for two different operations. I understand the convenience, but confusing none the less..

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

    Omg - thank you. I get it now!

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

    Very nice video ! Do you advice to wait for Svelte 5 before starting learning how to use Svelte?

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

      Absolutely not!

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

      @@Huntabyte Ok, thanks for the feedback.

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

    Nice example.
    Its a bit offtopic, but I would use a class instead of a factory function. Just because intellisense works better with classes, at least in vsc.

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

      You could certainly do that as well!

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

    What are your thoughts on snippets + render? Will you be refactoring shadcn-svelte/bits to use them instead of multiple .svelte files? Just subscribed to your channel. Thanks!

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

      Love them! I’ll have to see what makes the most sense once 5.0 is production ready!

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

    Why does one need the update function? And why not use get method?
    function set(color) {
    prev.set(get(curr));
    curr.set(color)
    }
    function undo() {
    curr.set(get(prev));
    prev.set(undefined);
    }

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

    I think this could potentially simplify some of those instances where we reach for svelte-subscribe, but I'm not exactly sure if my intuition is correct. I've always hated having Subscribe components polluting a page in order to solve what is essentially just a limitation of stores in their present form.

  • @Rafael-es5dp
    @Rafael-es5dp 10 місяців тому

    Hi there. just want to ask if there is a rich text editor that you can suggest? Thank you very much

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

    I hope u dont check the box on creating a vid on how to make these composable funcs because this is the superpower i want to be great at. Id love more of these and maybe take it to the next level of complexity. For example today I was trying to do this and trying to nest composable funcs like one composable func is create_counter() and another create_player_scores() so im trying to use the counter attatched to each player that gets added

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

      There will definitely be more to come, you can even have `$effect`s in these as well which can unlock even cooler things :)

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

    Nice Onee

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

    But if you use color across multiple components, do it update as store do?

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

      If you defined it in another file like `signals.js` and exported it from there, yes, it works the same way!

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

    By the way, you do not have to define an update function for stores, it's not part of the interface.
    The only things that matter for Svelte are subscribe & set.

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

      If I want it to provide the same API as the writable then I do.

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

      @@Huntabyte Well, yes, but it's useless most of the time.
      Update is primarily useful outside of components when writing stores and most stores are consumed within components, so unless you are going crazy with custom stores being used by other custom stores or functions in plain JS, you usually just don't need it.
      Just checked one of my applications, which has about 180 components and I use update in 2 TS files a total of 4 times.

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

      @@ELStalky It's a strange you point you're trying to make. It might not have been useful in your experience but it could be in someone else's.

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

      @@maelstrom57 I am just noting that if you are not writing a library, you don't have to bother with it most of the time so you can probably spare yourself the effort.

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

    I don't understand how $state is available from a normal .js file if it isn't included. How does that work?

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

      Compiler!

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

      @@Huntabyte But, it's supposed to work outside of Svelte files? 🤔

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

      @@ilu1994 The compiler can read more than just .svelte files!

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

    Why do we need get and set though?

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

      Rich Harris made a video on this on his UA-cam!

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

    looking at the update function really makes sense why this make sense to introduce runes.
    I felt Rich Harris speedrun the demo and didnt do it justice

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

    Is there a way to destructure store without losing reactivity?

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

      Unless there's some magical restriction I'm not aware of, you could simply use methods instead of getters/setters.
      {
      getCurr: () => curr, // etc...
      }
      const { getCurr } = withPrevSignals("green");

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

    For me, the store syntax is simpler, since you can pretty much understand it by knowing javascript, and signals feels more magical, and the fact that it usses setters and getters makes it event more complicated for newer devs (there are many articles against them)

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

      I disagree that signals are more magical than stores. The reactive syntax with stores is at least as magical, especially because it's not a native JS feature, and it's much harder to learn imo. Also, the fact that store reactivity has so many weird edge cases about when you can and can't use it is a significant complexity hurdle.

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

      I disagree that the store syntax is more simple. You have to first learn how stores work, how to update them, the updater callback it takes in, etc. vs. get curr() reads exactly like what it does.

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

    I'm on day 1 of a pattern i may really like. Make one giant composition function intended for a +page and all components that may be used on it.
    Define this func in independent js file and also define another var immediately after that calls that func to set as a global store. We then import that global var in any component and call methods
    You would instantly call say my_data_manager.init(data) when u get server data in export let data methods.
    Then u can put all the messy stuff in that and just import the pretty state and methods in components.
    Its day 1 tho ill keep building and evaluating

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

      I'm glad you're already experimenting with the different patterns. This update really adds a lot of composition power which I personally love the most about it!

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

      @@Huntabyte ya so many ideas to discover. Even things like init the composition func on the server somehow could be interesting since im sending data through func after i get

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

    How do we subscribe to Runes ($state)?

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

      You don’t have to subscribe!

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

    Will Svelte 5 break code in previous versions?

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

    I really don't get the need for runes, I'm sorry, what's stopping us from sticking an "await tick()" in between the assignment and next read inside the function?
    Cause as far as I can tell the only issue here is the component render delay, all it takes to fix the whole thing is one single 'await tick()'.
    Not to mention you only have this issue in .svelte files.
    At least it's opt in, hopefully the old "$:" syntax won't get deprecated in favor of runes, runes are much less readable.

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

    This store definition was great. But with derived stores it could have been way cleaner and easier to read. And compare

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

      Can you provide an example? I tried with derived at first but it ended up being more complicated in that derived is only called when the value of the store it depends on changes, so getting the prev value. Curious to see how you’d clean it up!

  • @SaumilShah-pn6wm
    @SaumilShah-pn6wm Рік тому +2

    Honestly, I felt extremely comfortable using stores.

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

    Cant' really understand what frontend frameworks which mostly are opinionated what they are trying to achieve... I need just dead simple CQRS pattern on the frontend, which libraries like Tanstack or RTK have baked in... Also if we talking about jumpwagon on observability (but rxjs was crap), it's the only missing feature of js language, besides types...

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

    sorry but I never saw where pople use Svelte store like this. It's not a real use case. Ussualy it's much much simpler and this is why runes not a replacement. Basicaly you implemented API/CRUD base on Store.

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

      yep, you just not realy understand how to work with Svelte store, this example is not legit. Even more - you example can be even easier to implement without $state !

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

      😂

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

      Sorry, for my emotional reaction. If somebody used a store like this it's a valid example but I never used stores like this, for me it's very unnatural.

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

      I would bet some libraries you regularly use have these patterns internally. Another thing to think about is maybe a lot of people haven’t used patterns like this _because_ it’s overly complex and annoying.

  • @darah.k3221
    @darah.k3221 Рік тому +3

    this way it's not Svelte anymore

  • @j.m.manhard
    @j.m.manhard Рік тому +1

    I find having to write "color.something" much more verbose than simply "$something". I like the experience when it's about writing the functionality but not when it's about using it.
    Defining props is much less clean with runes, binding to them is weird and no destructing is also annoying.

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

      Remember, stores are going absolutely nowhere. Meaning, if you have some sort of “global” state that’s a simple single value, you can still use a store! Maybe for something like “darkMode”. But for more complex state, like an object, you’d be doing the dot notation with stores anyway! (unless you destructured, which you can’t do in runes admittedly). Just remember that if your thought is “my global state was so simple it had no problems with stores” that’s great, you will forever be able to use them! Runes are meant to make the more complex parts more readable and performant!

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

    too much magic arrghh

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

      You think? I feel like Svelte 5 makes it feel _less_ magic than Svelte 4, but I embrace and appreciate the magic!

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

    I'd rather see some real world examples of new syntax without constantly comparing with the old way. It's distracting .

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

    Me: 🛌