Skip to content

Instantly share code, notes, and snippets.

@mehulkar
Created January 6, 2021 16:50
Show Gist options
  • Save mehulkar/4673aff6856e8f810efce90c6a145041 to your computer and use it in GitHub Desktop.
Save mehulkar/4673aff6856e8f810efce90c6a145041 to your computer and use it in GitHub Desktop.
Slow Route
import Component from '@ember/component';
export default class extends Component {
didUpdateAttrs() {
}
}
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
}
import EmberRouter from '@ember/routing/router';
import config from './config/environment';
const Router = EmberRouter.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
this.route('foo');
});
export default Router;
import Route from '@ember/routing/route';
export default class FooRoute extends Route {
model() {
return new Promise((resolve) => setTimeout(resolve, 2000));
}
afterModel() {
console.log('slow model resolved')
}
}
import Route from '@ember/routing/route';
export default Route.extend({
});
<h1>Demo</h1>
<LinkTo @route="index">Home</LinkTo>
<LinkTo @route="foo">Slow Route</LinkTo>
<p>Start on the home route and then go to the Slow Route. The Slow Route has a model hook that takes a second to resolve.</p>
{{outlet}}
<h2>Foo Route</h2>
<CustomImg @src="http://placekitten.com/400/500" />
<h2>Index Route</h2>
<CustomImg @src="http://placekitten.com/200/300" />
{
"version": "0.17.1",
"EmberENV": {
"FEATURES": {},
"_TEMPLATE_ONLY_GLIMMER_COMPONENTS": false,
"_APPLICATION_TEMPLATE_WRAPPER": true,
"_JQUERY_INTEGRATION": true
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.js",
"ember": "3.18.1",
"ember-template-compiler": "3.18.1",
"ember-testing": "3.18.1"
},
"addons": {
"@glimmer/component": "1.0.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment