3 ms·
> 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 p
by jamincan 4y ago
> 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.
- kevinak 4y agoYep! And to modify the data you use form actions :) it really is very beautiful once you get the full data flow
- markjaquith 4y agoFor 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.
- jamincan 4y agoI'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.