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
When we do HTML streaming, currently, async generators are the last ones to control the chunks better and render streaming lists incrementally (see example). But if we want to show a title with the number of elements rendered in the list, which is updated in streaming, it is currently impossible to do easily.
import{Database}from"bun:sqlite";constdb=newDatabase("db.sqlite");exportdefaultfunctionMovieList(){return(<><h2>Number of movies: {/* ??? */}</h2><ul><MovieItems/></ul></>);}// Streaming HTML from SQLite queryasyncfunction*MovieItems(){for(constmovieofdb.query("SELECT title, year FROM movies")){yield(<li>{movie.title} ({movie.year})
</li>);}}
Proposal: Add the yieldSame API to allow for the modification of the same chunk each time instead of increasing the number of chunks.
Example:
import{Database}from"bun:sqlite";constdb=newDatabase("db.sqlite");exportdefaultfunctionMovieList(){constmovies=db.query("SELECT title, year FROM movies");return(<><Titlemovies={movies}/><ul><MovieItemsmovies={movies}/></ul></>);}asyncfunction*Title({ movies }){leti=0;for(constmovieofmovies){yield(<h2>
Number of movies {++i}</h2>);}}// Modifying same chunk in Streaming HTMLTitle.yieldSame=true;// Streaming HTML from SQLite queryasyncfunction*MovieItems({ movies }){for(constmovieofmovies){yield(<li>{movie.title} ({movie.year})
</li>);}}
The text was updated successfully, but these errors were encountered:
When we do HTML streaming, currently, async generators are the last ones to control the chunks better and render streaming lists incrementally (see example). But if we want to show a title with the number of elements rendered in the list, which is updated in streaming, it is currently impossible to do easily.
Proposal: Add the
yieldSame
API to allow for the modification of the same chunk each time instead of increasing the number of chunks.Example:
The text was updated successfully, but these errors were encountered: