You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the era of generative AI, we often need to stream data to the client. In SvelteKit routes can return promises inside load transparently, that's good. I think it won't be hard to support async generators too.
For example, I use Svelte in a lot of GenAI related sites of mine. Usually I invoke streaming responses on the client side, via an API endpoint, but that's neither the most performant way, nor the besy UX. The API calling only happens after the full hydration, which is even slower on hardwares with bad network environment. If we can stream async iterators inside page load functions, that would save several seconds from users for each page load!
For now, there is actually a possible workaround:
Let's say you want to return a iterator which wouldn't yield more than 10,000 times. You can return a list with 10,000 promise instead, inside which the [i]-th promise will resolves when the async iterator yield the [i]-th times, or the iterator exhausted before that.
Describe the proposed solution
The same as how promises inside route loaders in sveltekit, like using trailing <script> with SSR.
Importance
would make my life easier
The text was updated successfully, but these errors were encountered:
Describe the problem
In the era of generative AI, we often need to stream data to the client. In SvelteKit routes can return promises inside
load
transparently, that's good. I think it won't be hard to support async generators too.For example, I use Svelte in a lot of GenAI related sites of mine. Usually I invoke streaming responses on the client side, via an API endpoint, but that's neither the most performant way, nor the besy UX. The API calling only happens after the full hydration, which is even slower on hardwares with bad network environment. If we can stream async iterators inside page load functions, that would save several seconds from users for each page load!
For now, there is actually a possible workaround:
Let's say you want to return a iterator which wouldn't yield more than 10,000 times. You can return a list with 10,000 promise instead, inside which the [i]-th promise will resolves when the async iterator yield the [i]-th times, or the iterator exhausted before that.
Describe the proposed solution
The same as how promises inside route loaders in sveltekit, like using trailing
<script>
with SSR.Importance
would make my life easier
The text was updated successfully, but these errors were encountered: