I just wanted to say again that you are doing an awesome job. I think I've seen your subs grow like 5x, and it's well deserved. I know you have a high bar, and I think you are on the right path - and deserving. Cheers!
@Huntabyte Жыл бұрын
Wow thanks for the kind words! I appreciate it! I am super thankful for the growth I’ve experience the last few months, I hope I can continue to deliver and meet expectations!
@blokche_dev Жыл бұрын
Oh! Interesting. Thanks for sharing. Love this short format. Much easier to digest 😅
@lian1238 Жыл бұрын
2:37 so you forgot to return await for b and c but it still worked. is arrow function implicitly returning? what is this called?
@jwankrho Жыл бұрын
No. Defining a function as "async" is simply a shorthand way of indicating that the function returns a new Promise object. This means that the function will resolve automatically, even if you don’t explicitly include a return statement.
@TruthWalker Жыл бұрын
Thanks!
@Huntabyte Жыл бұрын
Thank you Daniel, I appreciate that!
@radimnedved1401 Жыл бұрын
Is this still up to date? Can't find it in documentation
@kevinsaltarelli Жыл бұрын
This came ON TIME!!! Thank you very much :)
@pascalwidmer3875 Жыл бұрын
Thanks, this really speeds up things a lot. One question: how do you throw errors like this? I get Promise { }, how and at what point do I determine if the request has failed?
@Huntabyte Жыл бұрын
Check my video on ‘Defer’ which might help answer this question!
@Plunzi Жыл бұрын
Thanks, this is awesome I am actually in need for this rn. Thank you very much!
@LukasSkywalker_ Жыл бұрын
Thanks. Just yesterday I was using Promise.all. Did not know about this on Sveltekit, thanks.
@Huntabyte Жыл бұрын
You're welcome!
@MrAbuYT Жыл бұрын
Thanks for sharing this helpful content. I look forward to seeing more of it.
@johnpeap Жыл бұрын
Awesome man, I would never find this myself.
@jeremyikwuje Жыл бұрын
Thank you for this. Trying to improve the core web vital for a project, will try this tips out.
@ABsazerNer Жыл бұрын
that's will be the heart of my project now, I'll modify any function, please can you tell me if supabase self hosted a good choice, in your experience? if there's a better can you suggest
@Huntabyte Жыл бұрын
Unfortunately, I don't have experience self-hosting Supabase!
@adimardev1550 Жыл бұрын
very useful information. thank you so much... really appreciate.
@AakashGoplani Жыл бұрын
This is a great technique and you explained it quite well. I wish we had something similar for universal load functions as well :(
@gorbulevsvАй бұрын
Thank you, useful information!!
@nobodyshomeuk Жыл бұрын
How do you handle the return not existing on "PageData" when using the methods? Is there a way to properly type it in TypeScript?
@Huntabyte Жыл бұрын
You can edit the PageData interface of the app.d.ts file!
@nobodyshomeuk Жыл бұрын
@@Huntabyte I see! I would have to include the part about it being a promise too right? Thanks for the reply!
@TheOllieJT Жыл бұрын
Thank you for sharing!
@Huntabyte Жыл бұрын
You're welcome!
@AlexvanderValk Жыл бұрын
What happens if any of the promises rejects?
@Huntabyte Жыл бұрын
The closest error boundary is rendered.
@bjul Жыл бұрын
Awesome video, thank you very much!
@Huntabyte Жыл бұрын
You’re very welcome!
@kisaragi-hiu Жыл бұрын
In the final example, I think it's possible to put the fetch calls in the object being returned to save a wrapper function or two at the cost of that object looking more messy; is this correct? Thank you for teaching us various parts of SvelteKit regardless!
@Huntabyte Жыл бұрын
That is correct! I typically will move the functions elsewhere eventually so it’s nice to have them ready to cut and paste!
@cami7o Жыл бұрын
Hi Hunter! If my request is done to Supabase for example, and I want to return to the page only a member from the "data" object that I should receive if the request is ok, how can I get the response from the Promise? using 'then'? Thanks!
@SebastianEling Жыл бұрын
You should await the call. The await will. resolve the promise, so that you get the "pure" type.
@hanshurtig5943 Жыл бұрын
Would it be possible to do this also when using API endpoints? I've tried, but so far haven't gotten anywhere.
@LapaNaungi Жыл бұрын
Can i render my HTML before Load resolve ?
@LapaNaungi Жыл бұрын
This is the answer i was looking for kzbin.info/www/bejne/rYWpaqiro92GrKM
@deephousefridays1911 Жыл бұрын
Great info, thank you!
@Huntabyte Жыл бұрын
My pleasure!
@nextjust Жыл бұрын
Can you make a video about using Sveltekit and Graphql? How can we work with Graphql endpoints? What is the correct and safe method? Do we need to use any graphql gateway/package? I am eagerly waiting for your video, thanks for every contribution to the ecosystem.
@ihsanmohamad521 Жыл бұрын
houdini graphql are good
@HarunZafer-f3u6 ай бұрын
With SvelteKit 2, the top-level promises are no longer awaited
@Huntabyte5 ай бұрын
This is true!
@piquelchips89925 ай бұрын
@@Huntabyte So how would you go about doing this if they are not resolved. Do I resolve the promises with await? cause that brings us back to square one. I have also seen people mention Promise.all(). How would that work? Thanks again for the great videos!
@Lukehagar Жыл бұрын
Fantastic Video!
@Huntabyte Жыл бұрын
Thanks, Luke!
@jonathangamble Жыл бұрын
Confused on how to do error handling with this...
@insa19885 ай бұрын
Awesome 🎉
@hiranga Жыл бұрын
Super useful!
@Huntabyte Жыл бұрын
Glad it was helpful!
@jaideepshekhar4621 Жыл бұрын
Wait, am I missing something, or will just making promises obviously reduce time to the longest timeout, since nothing is actually happening, it's just waiting for end time. Otoh, fetching data is not waiting for time end, but you're actually doing something in that time?
@Huntabyte Жыл бұрын
The timeout was just a demonstration - I could have put actual fetch requests there but network speed can change slightly per request so I found it more difficult to explain that point.
@TechBuddy_ Жыл бұрын
Why wrap a single function call in a wrapper function can't we just remove the await and directly pass the promise as the return value??
@Huntabyte Жыл бұрын
You can certainly do this if the data doesn't require further transformation from the initial request! If I'm fetching from an API I will typically want to also do a `return await response.json()` after the `fetch` has resolved, which would require me to wrap them.
@TechBuddy_ Жыл бұрын
@@Huntabyte well I'd chain a couple thens ( I am pretty sure thens return a new promise but I may be dumb so take that with a grain of salt )
@Huntabyte Жыл бұрын
@@TechBuddy_ I think it's all a matter of personal preference, I just prefer to wrap them! I think it makes it easier for others to visualize how they could potentially wrap some of their existing logic!
@TechBuddy_ Жыл бұрын
@@Huntabyte so my way works too right ?
@sachahjkl Жыл бұрын
@@TechBuddy_ yes it does
@SheeceGardazi Жыл бұрын
waooo awesoem tut!
@paundrakkkrishna3214 Жыл бұрын
❤️
@Football-miracle Жыл бұрын
Please make a vidio how to send a massage with redirect in sveltekit
@benny-shen Жыл бұрын
nice tips
@Huntabyte Жыл бұрын
Thank you!
@tger3773 Жыл бұрын
ok
@tger3773 Жыл бұрын
ㅎㅎ
@underview8492 Жыл бұрын
How is this different from await Promise.all()?
@Huntabyte Жыл бұрын
It's not, it's just done for you :)
@nooalovern Жыл бұрын
or just: const [d1,d2,d3] = await Promise.all([res(3000), res(2000), res(1000)])
@Huntabyte Жыл бұрын
Of course, but SvelteKit does it automatically for you
@mody-pq8kd Жыл бұрын
Promise.all can solve this problem and make your code more readable
@rohitkharche7562 Жыл бұрын
I wonder if Promise.all() will also achieve the same result
@Huntabyte Жыл бұрын
That's essentially what SvelteKit already does for you when you return promises in your load functions 🔥
@rohitkharche7562 Жыл бұрын
@@Huntabyte so what if promises have interdependence on each other will that also tank performance
@Huntabyte Жыл бұрын
@@rohitkharche7562 Yeah because if you think about it - you would HAVE to wait for one promise to resolve before using those results in the next request! There's no getting around that case.
@carlosmastin9852 Жыл бұрын
Promise.all or Promise.allsettelled should get you the same results, but definitely nice that Sveltekit can do this for you