Skip to content

Instantly share code, notes, and snippets.

@scalvert
Forked from chadhietala/controllers.application.js
Last active April 16, 2017 23:43
Show Gist options
  • Save scalvert/2e0bac9e9534736fc115a2a3518ddaaf to your computer and use it in GitHub Desktop.
Save scalvert/2e0bac9e9534736fc115a2a3518ddaaf 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
}
nav {
width: 100%;
height: 50px;
background: #3b5998;
}
.item {
background: #fff;
border: 1px solid blue;
width: 100%;
padding: 10px;
overflow: hidden;
margin-bottom: 10px;
}
.image {
width: 50px;
height: 50px;
float: left;
}
.post-image {
display: block;
}
.post-content {
width: 300px;
height: 10px;
margin-left: 10px;
float: left;
}
.ghost-image {
background: #D3D3D3;
}
.ghost-text {
width: 300px;
height: 10px;
margin-left: 10px;
background: #D3D3D3;
float: left;
}
<nav>
NAV
</nav>
<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 class="item">
<img class="image post-image" src="http://lorempixel.com/50/50/">
<div class="post-content">
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 class="item">
<img class="image post-image" src="http://lorempixel.com/50/50/">
<div class="post-content">
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 class="item">
<img class="image post-image" src="http://lorempixel.com/50/50/">
<div class="post-content">
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 class="item">
<img class="image post-image" src="http://lorempixel.com/50/50/">
<div class="post-content">
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 class="item">
<div class="image ghost-image"></div>
<div class="ghost-text"></div>
<div class="ghost-text"></div>
<div class="ghost-text"></div>
</div>
<div class="item">
<div class="image ghost-image"></div>
<div class="ghost-text"></div>
<div class="ghost-text"></div>
<div class="ghost-text"></div>
</div>
<div class="item">
<div class="image ghost-image"></div>
<div class="ghost-text"></div>
<div class="ghost-text"></div>
<div class="ghost-text"></div>
</div>
<div class="item">
<div class="image ghost-image"></div>
<div class="ghost-text"></div>
<div class="ghost-text"></div>
<div class="ghost-text"></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