Last active
May 18, 2018 12:29
-
-
Save sukima/2a2bc29fd7d80976e78a3178aa07a684 to your computer and use it in GitHub Desktop.
Possible two-task approach
This file contains hidden or 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({ | |
actions: { | |
navIntro() { | |
this.transitionToRoute('index'); | |
}, | |
navExample() { | |
this.transitionToRoute('example'); | |
} | |
} | |
}); |
This file contains hidden or 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'; | |
const { | |
Controller, | |
computed: { reads, or } | |
} = Ember; | |
export default Controller.extend({ | |
theValue: or('model.{new,old}.value'), | |
isFetching: reads('model.new.isRunning'), | |
error: reads('model.new.error') | |
}); |
This file contains hidden or 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('example'); | |
}); | |
export default Router; |
This file contains hidden or 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 { task, timeout } from 'ember-concurrency'; | |
let uid = 1; | |
export default Ember.Route.extend({ | |
beforeModel() { | |
if (Ember.isNone(this.get('catalogTask.lastSuccessful.value'))) { | |
return this.get('catalogTask').perform(); | |
} | |
}, | |
model() { | |
return { | |
old: this.get('modelTask.lastSuccessful'), | |
new: this.get('modelTask').perform() | |
}; | |
}, | |
catalogTask: task(function * () { | |
yield timeout(1500); | |
return 'done'; | |
}).keepLatest().cancelOn('deactivate'), | |
modelTask: task(function * () { | |
yield timeout(1500); | |
return {title: `foober ${uid++}`}; | |
}).keepLatest().cancelOn('deactivate') | |
}); |
This file contains hidden or 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.11.0", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"hack_css": "https://cdnjs.cloudflare.com/ajax/libs/hack/0.7.7/hack.css", | |
"ember": "2.10.2", | |
"ember-data": "2.11.0", | |
"ember-template-compiler": "2.10.2", | |
"ember-testing": "2.10.2" | |
}, | |
"addons": { | |
"ember-concurrency": "latest" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment