// Streaming SSR demo: the shell flushes immediately, the slow section // streams in when its promise resolves. Run it: // node examples/streaming/server.js // // This page is server-rendered only (no hydration script): async holes // stream on the server, while client-side views must be synchronous. // Serializing streamed state for hydration is bankai v10 territory. import choo from '@choojs/core' import html from '@choojs/html' const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms)) export default function createApp ({ delay = 500 } = {}) { const app = choo() app.use((state) => { state.delay = delay }) app.route('/', mainView) app.route('*', mainView) return app } function mainView (state, emit) { return html`
This shell was flushed before the slow part finished.
${slowSection(state)} ` } async function slowSection (state) { await wait(state.delay) return html`