Skip to content

Instantly share code, notes, and snippets.

@Rich-Harris
Created December 4, 2017 20:19
Show Gist options
  • Save Rich-Harris/57c593fe51790055f871c3fadc342fa8 to your computer and use it in GitHub Desktop.
Save Rich-Harris/57c593fe51790055f871c3fadc342fa8 to your computer and use it in GitHub Desktop.
out-of-order streaming SSR
<body>
<header>
<h1>Hello world!</h1>
</header>
<main>
<noscript id='__await_block_0_start'></noscript>
<p>loading...</p>
<noscript id='__await_block_0_end'></noscript>
</main>
<footer>
copyright 2017 this guy
</footer>
</body>
<script>
removeNodesBetween(__await_block_0_start, __await_block_0_end);
__await_block_0_start.insertAdjacentHTML('afterend', '<p>the value is 42</p>');
__await_block_0_start.parentNode.removeChild(__await_block_0_start);
__await_block_0_end.parentNode.removeChild(__await_block_0_end);
function removeNodesBetween(start, end) {
// TODO implement
}
</script>
<body>
<header>
<h1>{{title}}</h1>
</header>
<main>
{{#await promise}}
<p>loading...</p>
{{then value}}
<p>the value is {{value}}</p>
{{catch error}}
<p>oh no! {{error.message}}</p>
{{/await}}
</main>
<footer>
copyright 2017 this guy
</footer>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment