Skip to content

Instantly share code, notes, and snippets.

@miketervela
Last active March 11, 2020 21:54
Show Gist options
  • Select an option

  • Save miketervela/9d45e84092486a6218d00557f719a67a to your computer and use it in GitHub Desktop.

Select an option

Save miketervela/9d45e84092486a6218d00557f719a67a to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Controller.extend({
gotoSubroute: function(id) {
},
appName: 'Ember Twiddle',
actions: {
gotoSubroute: function(id) {
}
}
});
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('subroute', {path:'subroute/:subroute_id'});
});
export default Router;
import Ember from 'ember';
export default Ember.Route.extend({
beforeModel: function() {
// return new Ember.RSVP.Promise(function(resolve, reject) {
// Ember.run.later(resolve, 1000);
// });
},
actions: {
gotoSubroute: function(id) {
}
}
});
import Ember from 'ember';
export default Ember.Route.extend({
model: function(params) {
return 8;
},
afterModel: function() {
return new Ember.RSVP.Promise(function(resolve, reject) {
Ember.run.later(resolve, 3000);
});
}
});
This is my application loading screen
<h1>Welcome to {{appName}}</h1>
{{#link-to 'subroute' 1}}Subroute{{/link-to}}
<br>
<br>
{{outlet}}
<br>
<br>
<h1>This is my loading screen</h1>
<h2> This is my subroute: {{model}} </h2>
{{#link-to "application"}}Application{{/link-to}}
import { run } from '@ember/runloop';
export default function destroyApp(application) {
run(application, 'destroy');
}
import Ember from 'ember';
import Application from '../../app';
import config from '../../config/environment';
const { run } = Ember;
const assign = Ember.assign || Ember.merge;
export default function startApp(attrs) {
let application;
let attributes = assign({rootElement: "#test-root"}, config.APP);
attributes.autoboot = true;
attributes.rootElement = '#ember-testing';
attributes = assign(attributes, attrs); // use defaults, but you can override;
run(() => {
application = Application.create(attributes);
application.setupForTesting();
application.injectTestHelpers();
});
return application;
}
import Application from '../app';
import config from '../config/environment';
import { setApplication } from '@ember/test-helpers';
import { start } from 'ember-qunit';
import { assign } from '@ember/polyfills';
let attributes = assign({ rootElement: '#main' }, config.APP);
setApplication(Application.create(attributes));
start();
{
"version": "0.16.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js",
"ember": "3.14.2",
"ember-template-compiler": "3.14.3",
"ember-testing": "3.14.3"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment