Created
August 14, 2017 04:39
-
-
Save kjhangiani/128d462ce1fa0acdebd696338ca3dc14 to your computer and use it in GitHub Desktop.
Test Active LinkTo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle' | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Mixin.create({ | |
isTransitioning: false, | |
actions: { | |
willTransition(transition){ | |
if (!this.get('isTransitioning')) { | |
transition.abort(); | |
this.set('isTransitioning', true); | |
//very small delay so that the loader shows before the transition gets stuck by the loading on next route | |
// NProgress.start(); | |
Ember.run.later(transition, transition.retry, 50); | |
} | |
return false; | |
}, | |
didTransition() { | |
this.set('isTransitioning', false); | |
return true; | |
}, | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Mixin.create({ | |
isTransitioning: false, | |
actions: { | |
willTransition(transition){ | |
if (!this.get('isTransitioning')) { | |
transition.abort(); | |
this.set('isTransitioning', true); | |
//very small delay so that the loader shows before the transition gets stuck by the loading on next route | |
// NProgress.start(); | |
//Ember.run.later(transition, transition.retry, 50); | |
// workaround from https://github.com/emberjs/ember.js/issues/10557 | |
// this does not work on ember-twiddle, but does work on the latest version | |
/* | |
function * params(transition) { | |
for (const info of transition.handlerInfos) { | |
for (const value of Object.values(info.params)) { | |
yield value; | |
} | |
} | |
} | |
Ember.run.later(this, () => { | |
const { url, name, queryParams } = transition.intent; | |
if (url) { | |
this.transitionTo(url); | |
} | |
else { | |
this.transitionTo(name, ...params(transition), { queryParams }); | |
} | |
}, 50); | |
*/ | |
// workaround for ember-twiddle | |
Ember.run.later(this, () => { | |
const { url, name, queryParams } = transition.intent; | |
if (url) { | |
this.transitionTo(url); | |
} | |
else { | |
let params = []; | |
for (const info of transition.handlerInfos) { | |
for (const value of Object.values(info.params)) { | |
params.push(value); | |
} | |
} | |
params.unshift(name); | |
params.push({ queryParams }); | |
this.transitionTo.apply(this, params); | |
} | |
}, 50); | |
} | |
return false; | |
}, | |
didTransition() { | |
this.set('isTransitioning', false); | |
return true; | |
}, | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import config from './config/environment'; | |
const Router = Ember.Router.extend({ | |
location: 'none', | |
rootURL: config.rootURL | |
}); | |
Router.map(function() { | |
this.route("some", { path: '/some' }, function() { | |
this.route('where', { path: '/where/:where_id' }, function() { | |
this.route('working', { path: '/working' }); | |
this.route('not-working', { path: '/not-working' }); | |
}); | |
}); | |
}); | |
export default Router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
model(params) { | |
return {}; | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
model(params) { | |
return Ember.Object.create({ name: 'where', id: params.id }); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import LoadableRouteMixin from 'twiddle/mixins/loadable-route-broken'; | |
export default Ember.Route.extend( | |
LoadableRouteMixin, { | |
model() { | |
return this.modelFor('some.where'); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import LoadableRouteMixin from 'twiddle/mixins/loadable-route-fixed'; | |
export default Ember.Route.extend( | |
LoadableRouteMixin, { | |
model() { | |
return this.modelFor('some.where'); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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