Using The Svelte Context API With Stores

  Рет қаралды 14,155

Joy of Code

Joy of Code

Күн бұрын

Пікірлер: 66
@JoyofCodeDev
@JoyofCodeDev Жыл бұрын
🔴 Patreon: www.patreon.com/joyofcode 💬 Discord: joyofcode.xyz/invite
@mykalesalad
@mykalesalad 9 ай бұрын
You have no idea how helpful this was, thank you for the consistent great videos.
@zhanezar
@zhanezar Жыл бұрын
thanks for all these tutorials on stores and context , its one of the parts of Svelte i struggled to understand but its so important
@JoyofCodeDev
@JoyofCodeDev Жыл бұрын
It's very powerful. 🔥
@nathanellis7819
@nathanellis7819 Жыл бұрын
Very happy to have found your channel. You are great! Please keep the svelteKit stuff coming. Thank you
@JoyofCodeDev
@JoyofCodeDev Жыл бұрын
Thank you! 😄
@amorfati8277
@amorfati8277 Жыл бұрын
Great Video 🔥. Thanks for your work for svelte. You are great source of information for Svelte. I like your teaching style as you use visual to explain the concepts better.
@JoyofCodeDev
@JoyofCodeDev Жыл бұрын
Thank you! 😄
@justingolden21
@justingolden21 Жыл бұрын
Very helpful video! Explains a lot in a simple manner and with great examples
@nickstaresinic9933
@nickstaresinic9933 Ай бұрын
Thanks, Matija, for the clear and concise explanation that solved a problem that arose today as I was refactoring some code. (FYI, I was directed here from a reddit Q: "How do I pass data from child to parent in Svelte 5?")
@irradiance730
@irradiance730 Жыл бұрын
Magnificent, thank you!
@tombil-certon
@tombil-certon Жыл бұрын
The thumbnail reminds me of the movie "The Emperor's New Groove" Love it
@JoyofCodeDev
@JoyofCodeDev Жыл бұрын
I see it now. 😄
@fallen_turbo
@fallen_turbo Жыл бұрын
This is a very helpful video thank you so much
@JoyofCodeDev
@JoyofCodeDev Жыл бұрын
You're welcome! 😄
@Steakss
@Steakss Жыл бұрын
Thanks @Joy of Code, appreciate you.
@JoyofCodeDev
@JoyofCodeDev Жыл бұрын
Thank you! 😌
@vlntsolo
@vlntsolo Жыл бұрын
Nice examples, thanks!
@alkmst-xyz
@alkmst-xyz Жыл бұрын
Great video and very practical example, love it! Perhaps a minor correction or doubt, I think it may not be necessary to give a parameter at the call site of getCount like getCount('count'), although I haven't tested it myself. Regardless, I am excited to use the Context API!
@JoyofCodeDev
@JoyofCodeDev Жыл бұрын
Yeah, I goofed up.
@twd2
@twd2 Жыл бұрын
I really like your tutorials !!!
@dc22199x
@dc22199x Жыл бұрын
Curious about your getCount() you passed an arg 'count' 😅 This is my first time to appreciate context api, there are plenty of things that it doesn't cover in the svelte docs, crazy stuff as always 💪🙏
@JoyofCodeDev
@JoyofCodeDev Жыл бұрын
It's a mistake! 😄
@workflowinmind
@workflowinmind 11 ай бұрын
8:40 why are you passing the sttring "count" to the get method?
@codermeo8129
@codermeo8129 Жыл бұрын
I love it ❤❤❤
@InMemoryOfNeo
@InMemoryOfNeo Жыл бұрын
you're awesome bro. please make more videos with typescript and sveltekit. Thx...
@thekokoserver
@thekokoserver Жыл бұрын
You are the best 🎉
@JoyofCodeDev
@JoyofCodeDev Жыл бұрын
Thank you! 😊
@efimgibsun7969
@efimgibsun7969 Жыл бұрын
Thank you ☺️ Why do you need to use setContex together with stores if you can use just stores?
@JoyofCodeDev
@JoyofCodeDev Жыл бұрын
The store value is shared across every component instance but context isn't when you want to have reusable components.
@anupam.sam9
@anupam.sam9 Жыл бұрын
The upside of this is, the store here is created only when the GrandParent component is used and Not globally, it's scoped to GrandParent components hierarchy below it. Thus Saving memory and also restricting to share this store's data globally to all components where it's not needed.
@cangurcan99
@cangurcan99 9 ай бұрын
Thank you for your great videos. This context + store is same as create store approach, is it right?
@thedelanyo
@thedelanyo Жыл бұрын
Succinctly explained and understood well. I'll almost be using a store whenever I use a context. Let's just say, contextual store 😅
Жыл бұрын
great video like always, thanks for the great content like always!!
@JoyofCodeDev
@JoyofCodeDev Жыл бұрын
Thank you! 😄
@omomer3506
@omomer3506 Жыл бұрын
Love it great stuff, If i may point out a human error, you exported getCount() woth no parameters but when calling it you wrote let count =getCount("count"), awesome job otherwise
@luczztem
@luczztem Жыл бұрын
impressive stuff
@bruhhhhh718
@bruhhhhh718 11 ай бұрын
this is perfect
@kvetoslavnovak423
@kvetoslavnovak423 Жыл бұрын
Great tutorial as always, Thank you ❤ Does the store and context usage have any bad consequences for SSR?
@JoyofCodeDev
@JoyofCodeDev Жыл бұрын
Not that I know of.
@hsdevelop5873
@hsdevelop5873 Жыл бұрын
great video
@Killtec
@Killtec Жыл бұрын
sveltekit supabase auth helpers with version 0.10 Add full server side support to auth helpers through PKCE, can you please make a video to showcase how we can use it to only call supabase via backend without showing our supabase client to the frontend. :)
@EvertvanBrussel
@EvertvanBrussel Жыл бұрын
Hey, I just saw this video and I really appreciate it. And now that Svelte 5 is being worked on and Rich has argued that a lot of places where in the past you would've used a store, you would not just use runes. And to be honest, I'm a little skeptical about whether runes can really replace stores for every use-case. But anyway, I was wondering if you'd be willing to make a new video that goes through this same subject again but discusses whether (and if yes, how) one should replace the store here with something rune-based in Svelte 5.
@JoyofCodeDev
@JoyofCodeDev Жыл бұрын
I wanted to look at some stores examples.
@Huntabyte
@Huntabyte Жыл бұрын
First 🔥🔥
@amorfati8277
@amorfati8277 Жыл бұрын
Two Svelte ambassadors, I like it ❤
@JoyofCodeDev
@JoyofCodeDev Жыл бұрын
You're fast! 😄
@AakashGoplani
@AakashGoplani Жыл бұрын
How can we extend this in SvelteKit? I have read `$page`, `$app` uses context API but I was not able to find a proper way to implement any such thing in SvelteKit!
@JoyofCodeDev
@JoyofCodeDev Жыл бұрын
SvelteKit uses the same technique for its stores using the context API and stores.
@connorcallahan2231
@connorcallahan2231 Жыл бұрын
How does " import { Grandparent, Parent, Child } from "$lib/components"; work? When I do it, it can't find the file, do you export them somehow into one object?
@JoyofCodeDev
@JoyofCodeDev Жыл бұрын
I export the components from `components/index.ts`.
@svelterust
@svelterust Жыл бұрын
@@JoyofCodeDev You can also create a path alias so that you can write $components instead, but you probably know this 😄
@v01d69
@v01d69 Жыл бұрын
i am very new to sveltekit and i have been watching your videos recently its very helpful! can u do a video on view transition api in svelte i am very confused about it
@JoyofCodeDev
@JoyofCodeDev Жыл бұрын
I already have a working example but I'm waiting for SvelteKit to merge a feature. 🤫
@nguyentruongnhan154
@nguyentruongnhan154 3 ай бұрын
why getCount's definition don't have any args, but you pass 'count' when you call it ?
@lying6624
@lying6624 Жыл бұрын
is it safe to use let variables? it feels unnatural after React. I haven't found information anywhere else on this
@JoyofCodeDev
@JoyofCodeDev Жыл бұрын
For what exactly?
@lying6624
@lying6624 Жыл бұрын
@@JoyofCodeDev you are initialazing variables using let. Is it safe? Because it is always better to use const, or svelte compiler change it to const?
@JoyofCodeDev
@JoyofCodeDev Жыл бұрын
@@lying6624 You have to use `let` because Svelte uses assignments to update values using regular JavaScript.
@lying6624
@lying6624 Жыл бұрын
@@JoyofCodeDev but is it safe to use let variables?
@JoyofCodeDev
@JoyofCodeDev Жыл бұрын
@@lying6624 That's how you do it in Svelte.
@bruhhhhh718
@bruhhhhh718 11 ай бұрын
by the way i think there is a mistake here... your function call has const count = getCount('count') but in the getCount function doesn't take any arguments.
@JoyofCodeDev
@JoyofCodeDev 11 ай бұрын
Yup! 😄
@nonefvnfvnjnjnjevjenjvonej3384
@nonefvnfvnjnjnjevjenjvonej3384 Жыл бұрын
svelte started off very minimalist and less boiler code. they are slowly moving towards complexity now. soon we will have usehooks here too.
@JoyofCodeDev
@JoyofCodeDev Жыл бұрын
If you have a simple component you should pass a prop or dispatch a custom event. The context API existed since Svelte was made and it solves a specific problem.
Create Beautiful Presentations With Svelte
32:59
Joy of Code
Рет қаралды 28 М.
Master The Svelte Context API
18:07
Joy of Code
Рет қаралды 8 М.
REAL or FAKE? #beatbox #tiktok
01:03
BeatboxJCOP
Рет қаралды 18 МЛН
It works #beatbox #tiktok
00:34
BeatboxJCOP
Рет қаралды 41 МЛН
Гениальное изобретение из обычного стаканчика!
00:31
Лютая физика | Олимпиадная физика
Рет қаралды 4,8 МЛН
Tuna 🍣 ​⁠@patrickzeinali ​⁠@ChefRush
00:48
albert_cancook
Рет қаралды 148 МЛН
Using JavaScript Libraries With Svelte Is Easy
17:37
Joy of Code
Рет қаралды 13 М.
Svelte 5's Secret Weapon: Classes + Context
18:14
Huntabyte
Рет қаралды 30 М.
Beginner SvelteKit: Context API
4:39
this.stephie
Рет қаралды 3,8 М.
Svelte Runes: Awesome or Awful?
11:40
Jack Herrington
Рет қаралды 15 М.
Forms Will Never Be the Same
10:10
Huntabyte
Рет қаралды 59 М.
Avoid Leaking User Data In Your SvelteKit App
24:31
Joy of Code
Рет қаралды 6 М.
The Svelte 5 Guide For Beginners
21:41
Joy of Code
Рет қаралды 35 М.
Use Svelte 5 Snippets To Reuse Markup Without Creating Components
17:41
Svelte makes Drag And Drop API easy!
15:08
Antonio Sarcevic
Рет қаралды 22 М.
Don't Sleep on Svelte 5
12:22
Huntabyte
Рет қаралды 45 М.
REAL or FAKE? #beatbox #tiktok
01:03
BeatboxJCOP
Рет қаралды 18 МЛН