Level Up Your Svelte Stores

  Рет қаралды 20,711

Huntabyte

Huntabyte

Күн бұрын

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/jos...
Svelte Store Docs:
svelte.dev/doc...
🚀 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 store contract
Svelte reactivity
Svelte local storage store
Svelte UI
Svelte dynamic data

Пікірлер: 68
@TechBuddy_
@TechBuddy_ Жыл бұрын
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
@hicoop
@hicoop Жыл бұрын
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 Жыл бұрын
Right!? It provides so much flexibility and can accommodate so many different use-cases!
@troyharris279
@troyharris279 Жыл бұрын
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.
@DennisIvy
@DennisIvy Жыл бұрын
Love your content man!
@Huntabyte
@Huntabyte Жыл бұрын
Thanks dude! Watched a lot of your Django content years ago it was very helpful!
@DennisIvy
@DennisIvy Жыл бұрын
I'm humbled ☺ @@Huntabyte
@ConnorMoody
@ConnorMoody Жыл бұрын
This is awesome! Super eloquent and clean way of doing this. Definitely going to make use of this in my projects
@zBrain0
@zBrain0 Жыл бұрын
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
@hello_world_104
@hello_world_104 Жыл бұрын
Wow this is great i often complicated my stores tring to have reusable functionality for different things. This will help me
@KevinMacKenzie61
@KevinMacKenzie61 Жыл бұрын
Man, you're breaking my brain....but in the best way possible. Thanks!!
@Huntabyte
@Huntabyte Жыл бұрын
Hahaha it’s not a must use or anything, just there if you find yourself needing it!
@DeviantFox
@DeviantFox Жыл бұрын
Svelte 5 is going to make this even easier with Runes (Signals)
@init1508
@init1508 Жыл бұрын
Coool, feels like some OOP stuff
@kyrregjerstad
@kyrregjerstad Жыл бұрын
This is great! Gonna go digging through the MeltUI sourecode now :D
@ScriptRaccoon
@ScriptRaccoon Жыл бұрын
Awesome explanation!
@Huntabyte
@Huntabyte Жыл бұрын
Thank you!
@matanon8454
@matanon8454 Жыл бұрын
@jayc413
@jayc413 Жыл бұрын
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
@masterhacker
@masterhacker Жыл бұрын
Awesome work, this will come in handy!
@hello_world_104
@hello_world_104 Жыл бұрын
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
@humbletitan8374
@humbletitan8374 Жыл бұрын
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 Жыл бұрын
soon!
@rogerpence
@rogerpence Жыл бұрын
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!
@alisareini
@alisareini Жыл бұрын
i love u hunta
@NotAllHeroesWearCapes-101
@NotAllHeroesWearCapes-101 Жыл бұрын
this is next next level shit .. impressive.. thanks for sharing !
@Huntabyte
@Huntabyte Жыл бұрын
You're welcome!
@fakiri25
@fakiri25 Жыл бұрын
Great content! How did you do the auto-complete at 5:02 Is it a VS Code extension?
@Huntabyte
@Huntabyte Жыл бұрын
GitHub Copilot!
@hello_world_104
@hello_world_104 Жыл бұрын
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 Жыл бұрын
Done :)
@andreas.soderlund
@andreas.soderlund Жыл бұрын
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?
@mauricepasternak6504
@mauricepasternak6504 Жыл бұрын
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 Жыл бұрын
Thank you!
@sexymeal2427
@sexymeal2427 Жыл бұрын
If you're dealing with code that's client side only with SSR on then always check if `browser` is true before doing anything
@ceocheema
@ceocheema Жыл бұрын
Thanks! 🙂
@pieter-jan1000
@pieter-jan1000 Жыл бұрын
The value of the count writable is gone once I switch pages. Do you know why?
@accountwizardindia8171
@accountwizardindia8171 Жыл бұрын
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() {"
@pascaltib
@pascaltib Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
@@HuntabyteNo worries! I understand thanks for the advice!
@hello_world_104
@hello_world_104 Жыл бұрын
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 Жыл бұрын
you'd have to take the object down another level, so: return { storeA: { ...storeA }, storeB: { ...storeB }, }
@hello_world_104
@hello_world_104 Жыл бұрын
@@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.
@JoyofCodeDev
@JoyofCodeDev Жыл бұрын
First
@Huntabyte
@Huntabyte Жыл бұрын
My guy!
@JoyofCodeDev
@JoyofCodeDev Жыл бұрын
@@Huntabyte Great video! 😄
@Huntabyte
@Huntabyte Жыл бұрын
@@JoyofCodeDev Thank you ❤
@hello_world_104
@hello_world_104 Жыл бұрын
Commenting just to feel like im part of this elite gang
@Huntabyte
@Huntabyte Жыл бұрын
You are a part of it!
@gadgetboyplaysmc
@gadgetboyplaysmc Жыл бұрын
One thing I miss about React were the hooks. I really like the pattern at 3:00
@drivebuss8079
@drivebuss8079 Жыл бұрын
You are looking very handsome.
@JeffPohlmeyer
@JeffPohlmeyer Жыл бұрын
Look at you being all fancy with the video of yourself in the corner
@Huntabyte
@Huntabyte Жыл бұрын
Haha just giving it a shot in this one but feel like it really helps with the overall pace of the video!
@AlanDanielx
@AlanDanielx Жыл бұрын
Looks so complex, prefer using stores in another way
@Huntabyte
@Huntabyte Жыл бұрын
How do you use them? I guess this is "supposed" to be more complex as you're extending the base functionality of stores!
@rlBrave
@rlBrave Жыл бұрын
I wish this tutorial would exist in german so I could understand that complex stuff 😂
@Мирбезхантов
@Мирбезхантов Жыл бұрын
So it's either brain or muscle...
@Huntabyte
@Huntabyte Жыл бұрын
That's a wiener, not a brain :)
@windar2390
@windar2390 Жыл бұрын
Unfortunate timing of this video. Right before the Svelte 5 runes.
@Huntabyte
@Huntabyte Жыл бұрын
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 10 ай бұрын
FUCKING TYPESCRIPT
Don't Sleep on Svelte 5
12:22
Huntabyte
Рет қаралды 46 М.
Svelte 5's Secret Weapon: Classes + Context
18:14
Huntabyte
Рет қаралды 33 М.
小丑女COCO的审判。#天使 #小丑 #超人不会飞
00:53
超人不会飞
Рет қаралды 16 МЛН
1% vs 100% #beatbox #tiktok
01:10
BeatboxJCOP
Рет қаралды 67 МЛН
Forms Will Never Be the Same
10:10
Huntabyte
Рет қаралды 61 М.
Best UI Library for Svelte
16:13
Huntabyte
Рет қаралды 112 М.
Svelte's ecosystem is amazing, actually
17:38
Nev the Dev
Рет қаралды 2,6 М.
Zod finally has competition (...created by Zod?)
12:28
Theo - t3․gg
Рет қаралды 44 М.
Using The Svelte Context API With Stores
10:17
Joy of Code
Рет қаралды 14 М.
Better Protected Route Redirects
7:58
Huntabyte
Рет қаралды 29 М.
Svelte UI Libraries Have Leveled Up
12:14
Huntabyte
Рет қаралды 65 М.
Using Svelte Stores With Svelte 5 Runes To Create Runed Stores
18:59
The Only Unbreakable Law
53:25
Molly Rocket
Рет қаралды 363 М.
Beginner SvelteKit: Stores
8:20
this.stephie
Рет қаралды 9 М.