-
-
Save PierBover/e3598c5174cf246388f4a25ed9217467 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addEventListener('fetch', event => { | |
event.respondWith(streamResponse(event)) | |
}); | |
async function streamResponse (event) { | |
let readable = new ReadableStream({ | |
start (controller) { | |
setInterval(() => { | |
controller.enqueue('Hello stream!' + '\n'); | |
}, 1000); | |
} | |
}); | |
return new Response(readable, { | |
status: 200 | |
}) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment