Skip to content

Streaming promises in load function #502

Open
@mihaipoenaru

Description

@mihaipoenaru

Is your feature request related to a problem? Please describe.
I have some slow data that needs to be fetched from a database, which pre-populates the form. I don't want the user to wait 4 seconds for the page to load, since the form itself is not the main feature of the page, so I use an {#await} block to show a spinner while the data is dynamically streamed, like in this documentation: https://svelte.dev/docs/kit/load#Streaming-with-promises

From what I've dug around, zod does support promises but no matter how much I fiddled with it, superforms does not want to accept a promise on the server for superValidate

Describe the solution you'd like
To accept a z.promise and integrate with an await block somehow.

Describe alternatives you've considered
I tried to return the Promise result from superValidate on the server, and then await that on the client, but the resulting code was quite disgusting and didn't really work at all, especially trying to use enhance

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions