Level Up Your Svelte Stores

แชร์
ฝัง
  • เผยแพร่เมื่อ 16 ก.ย. 2023
  • In this video, we'll take a closer look at extending Svelte stores to add custom functionality, overrides, and more.
    Thomas Lopes (Creator of Melt UI)
    / thomasglopes
    github.com/tglide
    Joshua Nussbaum (Creator of Svelte Local Storage Store)
    / joshnuss
    github.com/joshnuss
    Svelte Store Docs:
    svelte.dev/docs/svelte-store
    🚀 Modern SaaS Course: hbyt.us/modern-saas
    💬 Discord: hbyt.us/discord
    🐦 Twitter: hbyt.us/twitter
    🖥️ Setup Stuff: hbyt.us/gear
    📃 Topics Covered:
    - Svelte stores
    - Svelte writable
    - Svelte custom store
    - Svelte store contract
    - Svelte reactivity
    - Svelte local storage store
    - Svelte UI
    - Svelte dynamic data

ความคิดเห็น • 68

  • @hicoop
    @hicoop 10 หลายเดือนก่อน +23

    Never thought of returning a destructed store. I guess a store is just an object with store-like attributes, not by some weird Class you have to initialize. Svelte always impresses. Nice vid

    • @Huntabyte
      @Huntabyte  10 หลายเดือนก่อน +2

      Right!? It provides so much flexibility and can accommodate so many different use-cases!

  • @ConnorMoody
    @ConnorMoody 10 หลายเดือนก่อน

    This is awesome! Super eloquent and clean way of doing this. Definitely going to make use of this in my projects

  • @TechBuddy_
    @TechBuddy_ 10 หลายเดือนก่อน +5

    I've been doing this for like 6 months now and feels soo good. Svelte stores and the flip animation are the best parts of svelte imo

  • @troyharris279
    @troyharris279 10 หลายเดือนก่อน +3

    Im still getting my fundamentals with HTML CSS and JavaScript, but seeing this makes me want to jump into Svelte immediately.
    Thank you for the videos, I feel like I can make all my dream sites once I start with Svelte.

  • @DeviantFox
    @DeviantFox 10 หลายเดือนก่อน +5

    Svelte 5 is going to make this even easier with Runes (Signals)

  • @kyrregjerstad
    @kyrregjerstad 10 หลายเดือนก่อน

    This is great! Gonna go digging through the MeltUI sourecode now :D

  • @zBrain0
    @zBrain0 10 หลายเดือนก่อน +2

    I actually did this just today to implement a generic responsive array store. So it has push and pop and filter, but under the hood it runs the update function so you can treat it like a regular array but you don't have to do any reassignment to get the UI to update. As a nice added bonus it allows me to declare my arrays as const

  • @DennisIvy
    @DennisIvy 10 หลายเดือนก่อน +3

    Love your content man!

    • @Huntabyte
      @Huntabyte  10 หลายเดือนก่อน

      Thanks dude! Watched a lot of your Django content years ago it was very helpful!

    • @DennisIvy
      @DennisIvy 10 หลายเดือนก่อน

      I'm humbled ☺ @@Huntabyte

  • @alwayzsmarter
    @alwayzsmarter 10 หลายเดือนก่อน +3

    Wow this is great i often complicated my stores tring to have reusable functionality for different things. This will help me

  • @init1508
    @init1508 6 หลายเดือนก่อน

    Coool, feels like some OOP stuff

  • @KevinMacKenzie61
    @KevinMacKenzie61 10 หลายเดือนก่อน +9

    Man, you're breaking my brain....but in the best way possible. Thanks!!

    • @Huntabyte
      @Huntabyte  10 หลายเดือนก่อน +1

      Hahaha it’s not a must use or anything, just there if you find yourself needing it!

  • @ScriptRaccoon
    @ScriptRaccoon 10 หลายเดือนก่อน +1

    Awesome explanation!

    • @Huntabyte
      @Huntabyte  10 หลายเดือนก่อน

      Thank you!

  • @ceocheema
    @ceocheema 10 หลายเดือนก่อน

    Thanks! 🙂

  • @masterhacker
    @masterhacker 10 หลายเดือนก่อน +1

    Awesome work, this will come in handy!

  • @alwayzsmarter
    @alwayzsmarter 10 หลายเดือนก่อน

    this and runes has me now shifting my mindset to a similar approach to this but pure js putting all my state in let state = {} and handling state changes with an on update func like u demonstrated. I like the idea so far but we'll see if I can keep the code clean like this still for a more complex use case

  • @nuttbaked
    @nuttbaked 10 หลายเดือนก่อน +2

    another banger as usual

  • @dheerajs2838
    @dheerajs2838 10 หลายเดือนก่อน +1

    this is next next level shit .. impressive.. thanks for sharing !

    • @Huntabyte
      @Huntabyte  10 หลายเดือนก่อน

      You're welcome!

  • @matanon8454
    @matanon8454 10 หลายเดือนก่อน +2

  • @jayc413
    @jayc413 10 หลายเดือนก่อน

    Is there going to be a point where you the pass videos for a another application you build with the knowlwdgw of the previous videos. Your tutorials and svelte tips have been super helpful . Much love

  • @mauricepasternak6504
    @mauricepasternak6504 10 หลายเดือนก่อน +4

    Suggestion for another video to leap-frog off this one: How can one avoid the pitfalls of custom Svelte stores (and/or higher order stores) in SvelteKit when SSR is at play and when those custom stores make use of clientside-only objects like window, document, intersectionObserver, etc.

    • @Huntabyte
      @Huntabyte  10 หลายเดือนก่อน

      Thank you!

    • @sexymeal2427
      @sexymeal2427 10 หลายเดือนก่อน

      If you're dealing with code that's client side only with SSR on then always check if `browser` is true before doing anything

  • @fakiri25
    @fakiri25 9 หลายเดือนก่อน +1

    Great content! How did you do the auto-complete at 5:02 Is it a VS Code extension?

    • @Huntabyte
      @Huntabyte  9 หลายเดือนก่อน +1

      GitHub Copilot!

  • @andreas.soderlund
    @andreas.soderlund 10 หลายเดือนก่อน

    What do I see, object composition, aka object orientation! Hard not to end up there eventually. 😅 I was thinking about the callback method of updating that you show, how about using the subscribe method of the stores? Any disadvantage?

  • @alisareini
    @alisareini 10 หลายเดือนก่อน

    i love u hunta

  • @humbletitan8374
    @humbletitan8374 10 หลายเดือนก่อน +1

    going to have to watch these a few times before it sinks in. wonder what you think about stores since we are getting runes. I understand they are supposed to simplify reactivity. But the mental model of stores worked for me. my data lived somewhere outside all components, and some components could come visit when they needed a bit of that data. Now...i need more explainer videos, though Joy of code clarified things a bit better than Rich did , IMO

    • @Huntabyte
      @Huntabyte  10 หลายเดือนก่อน

      soon!

  • @accountwizardindia8171
    @accountwizardindia8171 10 หลายเดือนก่อน

    I have no idea getting an error (parse-error) at const count
    "import { writable } from "svelte/store";
    export function createCountStore (initialValue: number) {
    **const** count = writable(initialValue);
    function increment() {"

  • @rogerpence
    @rogerpence 9 หลายเดือนก่อน +1

    As of Oct 2023, this code doesn't work. The arg signature for Svelte's Updater is now "export type Updater = (target_value: T, value: T) => T;" (I don't know when it changed). How should this code be changed to make Updater happy? Thank you!

  • @pieter-jan1000
    @pieter-jan1000 9 หลายเดือนก่อน

    The value of the count writable is gone once I switch pages. Do you know why?

  • @alwayzsmarter
    @alwayzsmarter 10 หลายเดือนก่อน

    Can u do this exact video again but with runes and explain the benefit because I feel like the direction runes was heading was basically to this which u did with current svelte. Ill prob at least try and recode my stores similar to this at least in preperation for smoother transition

    • @Huntabyte
      @Huntabyte  10 หลายเดือนก่อน +1

      Done :)

  • @alwayzsmarter
    @alwayzsmarter 10 หลายเดือนก่อน

    so can i not return multiple store vals? like u spread ...count but i tried also returning is_loading and calling like $counter.is_loading does not update like $counter does. I can use get(counter.is_loading) but that doesnt update live. maybe this is what runes fixes
    maybe this is what vue 3 has with the ref and whatever i forget but like maybe i should just do const return_vals = writable({ count: 0, is_loading: false }) but then i guess that makes all the other funcs slighly more complex since cant just do count.update(n => n +1) since nested a level

    • @Huntabyte
      @Huntabyte  10 หลายเดือนก่อน +1

      you'd have to take the object down another level, so:
      return {
      storeA: { ...storeA },
      storeB: { ...storeB },
      }

    • @alwayzsmarter
      @alwayzsmarter 10 หลายเดือนก่อน

      @@Huntabyte ohh i see i gave up on that after not getting to work and went pure js mode. A lot of experimenting and deep thinking today. Confusion but progress nonetheless and having someone like u educating immensely helps my problem solving.

  • @drivebuss8079
    @drivebuss8079 10 หลายเดือนก่อน

    You are looking very handsome.

  • @AlanDanielx
    @AlanDanielx 10 หลายเดือนก่อน

    Looks so complex, prefer using stores in another way

    • @Huntabyte
      @Huntabyte  10 หลายเดือนก่อน

      How do you use them? I guess this is "supposed" to be more complex as you're extending the base functionality of stores!

  • @pascaltib
    @pascaltib 9 หลายเดือนก่อน

    Thanks for the amazing content. Has been helping me a lot. Keep it up!
    P.S.
    (This might be a crazy longshot and also not the reason I tipped)
    Would you be willing to give me some help (paid of course) and look over a sveltekit project I am building? Absolutely no issue if you are not available for this sort of thing

    • @Huntabyte
      @Huntabyte  8 หลายเดือนก่อน +1

      Hey thanks so much for the tip, I appreciate it! Unfortunately I'm a bit strapped for time, as you may have noticed since I haven't published in video in a bit. If you join the discord server myself or one of the others can try our best to help you with whatever issues you're having!

    • @pascaltib
      @pascaltib 8 หลายเดือนก่อน

      @@HuntabyteNo worries! I understand thanks for the advice!

  • @JoyofCodeDev
    @JoyofCodeDev 10 หลายเดือนก่อน +2

    First

    • @Huntabyte
      @Huntabyte  10 หลายเดือนก่อน

      My guy!

    • @JoyofCodeDev
      @JoyofCodeDev 10 หลายเดือนก่อน

      @@Huntabyte Great video! 😄

    • @Huntabyte
      @Huntabyte  10 หลายเดือนก่อน

      @@JoyofCodeDev Thank you ❤

    • @alwayzsmarter
      @alwayzsmarter 10 หลายเดือนก่อน +2

      Commenting just to feel like im part of this elite gang

    • @Huntabyte
      @Huntabyte  10 หลายเดือนก่อน +1

      You are a part of it!

  • @rlBrave
    @rlBrave 10 หลายเดือนก่อน

    I wish this tutorial would exist in german so I could understand that complex stuff 😂

  • @gadgetboyplaysmc
    @gadgetboyplaysmc 10 หลายเดือนก่อน

    One thing I miss about React were the hooks. I really like the pattern at 3:00

  • @JeffPohlmeyer
    @JeffPohlmeyer 10 หลายเดือนก่อน +1

    Look at you being all fancy with the video of yourself in the corner

    • @Huntabyte
      @Huntabyte  10 หลายเดือนก่อน

      Haha just giving it a shot in this one but feel like it really helps with the overall pace of the video!

  • @user-lm2sh1cx8i
    @user-lm2sh1cx8i 10 หลายเดือนก่อน

    So it's either brain or muscle...

    • @Huntabyte
      @Huntabyte  10 หลายเดือนก่อน

      That's a wiener, not a brain :)

  • @windar2390
    @windar2390 10 หลายเดือนก่อน +1

    Unfortunate timing of this video. Right before the Svelte 5 runes.

    • @Huntabyte
      @Huntabyte  10 หลายเดือนก่อน +1

      By design :) but stores aren't going anywhere for at least a few major versions, you just will find yourself reaching for them less.

  • @jamesfreeman1530
    @jamesfreeman1530 3 หลายเดือนก่อน

    FUCKING TYPESCRIPT