News for hackers. Stuff that matters.
Re:Thoughts on Svelte by jamincan on Monday March 27, 2023 @07:54AM (#35325497)
> I like the idea, but in practice I always ended up refactoring it out. There was always something else I needed to do after the Promise resolved or rejected prior to rendering, and I didn't want to run that logic every time I used the service.

> The logic also didn't belong inline in the rendering code, though. So where does it go?

I think the idea would normally be that you would handle loading the data in +page.ts and do any transformations there, and only deal with rendering and ui elements in the +page.svelte file.

Re:Thoughts on Svelte by kevinak on Monday March 27, 2023 @09:21AM (#35326351)
Yep! And to modify the data you use form actions :) it really is very beautiful once you get the full data flow
Re:Thoughts on Svelte by markjaquith on Monday March 27, 2023 @12:24PM (#35328662)
For performance reasons, you might not want to wait for promises to resolve in your load function, though. My app got way faster once I switched to streaming promises.
Re:Thoughts on Svelte by jamincan on Monday March 27, 2023 @12:32PM (#35328770)
I'm admittedly a JS/TS and Svelte novice, but I think you can still do the transformations within your load function, just making sure they're part of a promise you return.