Streamed hydration for Angular, live
One page, one slow widget
This page was streamed. Its shell arrived at once. The widget needs data that takes 5 seconds, so it followed in a later piece of the same response, and Angular hydrated it when it landed.
Watch it happen
Run it again- Shell arriveswaiting
- Widget HTML arriveswaiting
- Widget hydrateswaiting
Placeholder. This came with the shell. The server is still fetching the widget's data; the response stays open until it can send the widget.
This page holds hydration back for 2 seconds, so you can see the widget before and after. Normally it follows the widget's HTML by about a millisecond.
Look closer
Walkthrough
Four blocks on one page: one nested in another, one that waits for the whole response, and text outside any block. An event log records each step.
Response inspector
The walkthrough's raw response, cut into the pieces the server wrote, with the size, contents and arrival time of each.
Angular Movies
A real app streamed the same way: a movie browser on the TMDB API, where each list and the cast arrive as their requests finish.
Read about it
This site shows streaming as it happens. The docs explain it.
The code for a page like this
A
@deferblock, an ordinaryHttpClientrequest and two providers, and the rules for writing them.Why stream out of order
What it buys a page, what it costs, and where the idea comes from.
One response, flush by flush
What each piece of a response carries, and when each part of the page hydrates.
Get started
What the packages need, and the setup for where your app runs.