Skip to content

Instantly share code, notes, and snippets.

@chadhietala
Last active April 14, 2017 20:32
Show Gist options
  • Save chadhietala/985ed892c63b8a5057ae7d95b4b635d6 to your computer and use it in GitHub Desktop.
Save chadhietala/985ed892c63b8a5057ae7d95b4b635d6 to your computer and use it in GitHub Desktop.
Pathless Routes For Deferred Rendering
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
this.route('feed-shell', { path: '/' }, function() {
this.route('feed', { path: '' })
})
});
export default Router;
import Ember from 'ember';
export default Ember.Route.extend({
model() {
return new Promise((r) => {
setTimeout(() => {
r()
}, 1000)
})
}
});
import Ember from 'ember';
export default Ember.Route.extend({
});
body {
margin: 0;
padding: 0;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
background: #e9ebee
}
<div style="width: 100%; height: 50px; background: #3b5998">
NAV
</div>
<p>This illustrates using path-less routes to load data that takes a long time to load. The effect is that you can get very fast TTFP and potentially TTFI.</p>
<br>
<br>
{{outlet}}
<br>
<br>
<div>
<div style="background: #fff; border: 1px solid blue; width: 100%; padding: 10px; overflow: hidden; margin-bottom: 10px;">
<div style="width: 50px; height: 50px; float: left; ">
<img src="http://lorempixel.com/50/50/">
</div>
<div style="width: 300px; height: 10px; margin-left: 10px; float: left; ">
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.
</div>
</div>
<div style="background: #fff; border: 1px solid blue; width: 100%; padding: 10px; overflow: hidden; margin-bottom: 10px;">
<div style="width: 50px; height: 50px; float: left; ">
<img src="http://lorempixel.com/50/50/">
</div>
<div style="width: 300px; height: 10px; margin-left: 10px; float: left; ">
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.
</div>
</div>
<div style="background: #fff; border: 1px solid blue; width: 100%; padding: 10px; overflow: hidden; margin-bottom: 10px;">
<div style="width: 50px; height: 50px; float: left; ">
<img src="http://lorempixel.com/50/50/">
</div>
<div style="width: 300px; height: 10px; margin-left: 10px; float: left; ">
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.
</div>
</div>
<div style="background: #fff; border: 1px solid blue; width: 100%; padding: 10px; overflow: hidden; margin-bottom: 10px;">
<div style="width: 50px; height: 50px; float: left; ">
<img src="http://lorempixel.com/50/50/">
</div>
<div style="width: 300px; height: 10px; margin-left: 10px; float: left; ">
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.
</div>
</div>
</div>
<div style="border: 1px solid red; padding: 30px;">
<h1>Shell</h1>
<p>Meant to render almost instantly</p>
{{outlet}}
</div>
<div>
<div style="background: #fff; border: 1px solid blue; width: 100%; padding: 10px; overflow: hidden; margin-bottom: 10px;">
<div style="width: 50px; height: 50px; background: #D3D3D3; float: left; "></div>
<div style="width: 300px; height: 10px; margin-left: 10px; background: #D3D3D3; float: left; "></div>
<div style="width: 300px; height: 10px; margin-top: 10px; margin-left: 10px; background: #D3D3D3; float: left; "></div>
<div style="width: 300px; height: 10px; margin-top: 10px; margin-left: 10px; background: #D3D3D3; float: left; "></div>
</div>
<div style="background: #fff; border: 1px solid blue; width: 100%; padding: 10px; overflow: hidden; margin-bottom: 10px;">
<div style="width: 50px; height: 50px; background: #D3D3D3; float: left; "></div>
<div style="width: 300px; height: 10px; margin-left: 10px; background: #D3D3D3; float: left; "></div>
<div style="width: 300px; height: 10px; margin-top: 10px; margin-left: 10px; background: #D3D3D3; float: left; "></div>
<div style="width: 300px; height: 10px; margin-top: 10px; margin-left: 10px; background: #D3D3D3; float: left; "></div>
</div>
<div style="background: #fff; border: 1px solid blue; width: 100%; padding: 10px; overflow: hidden; margin-bottom: 10px;">
<div style="width: 50px; height: 50px; background: #D3D3D3; float: left; "></div>
<div style="width: 300px; height: 10px; margin-left: 10px; background: #D3D3D3; float: left; "></div>
<div style="width: 300px; height: 10px; margin-top: 10px; margin-left: 10px; background: #D3D3D3; float: left; "></div>
<div style="width: 300px; height: 10px; margin-top: 10px; margin-left: 10px; background: #D3D3D3; float: left; "></div>
</div>
<div style="background: #fff; border: 1px solid blue; width: 100%; padding: 10px; overflow: hidden; margin-bottom: 10px;">
<div style="width: 50px; height: 50px; background: #D3D3D3; float: left; "></div>
<div style="width: 300px; height: 10px; margin-left: 10px; background: #D3D3D3; float: left; "></div>
<div style="width: 300px; height: 10px; margin-top: 10px; margin-left: 10px; background: #D3D3D3; float: left; "></div>
<div style="width: 300px; height: 10px; margin-top: 10px; margin-left: 10px; background: #D3D3D3; float: left; "></div>
</div>
</div>
{
"version": "0.12.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.12.0",
"ember-template-compiler": "2.12.0",
"ember-testing": "2.12.0"
},
"addons": {
"ember-data": "2.12.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment