Three dishes come from the market through an async generator: Mr. Tono’s for await…of serves them one at a time. When is the next dish asked for, and what…
The key idea
A generator pauses at yield until the loop asks again
Try it in this playground
See the sate served before the rendang is fetched With an async generator, the first dish is served at 200 ms. That is streaming.
Make Mr. Tono eat for longer The next runner only sets off once Mr. Tono is done: the generator waits for the loop body.
Drop the star for await…of over a promise: an instant TypeError.
break, then see finally still run 'dapur tutup' prints though the loop stops halfway.