Basically, Streams 🌊
So something (relatively) new and fun in browsers, are these two APIs: ReadableStream and WritableStream. 😮
What they allow you to do, is basically send and receive chunks of things progressively (that then combine into the final large thing), as opposed to moving around entire things.
Below is a living example of streaming vs. conventional transfer:
I am a bunch of text who lives here, but I'm bored of living here so I want to move trololololololol.
Pretty cool, huh?
So basically, what's happening is this:
- Someone clicks "Move me!"
- We create a ReadableStream, whose source is the textContent of the left column
- The stream removes and queues each letter, one by one, every few milliseconds
- This stream is piped into a `receiverStream`, that writes it to the right column.
All of this is visible in the source code (index.js). There's more cool things in the examples folder. Go, explore, have fun! Woooo!
More Examples 🎉
Further Reading: WhatWG Spec