Last active
October 17, 2018 14:16
-
-
Save jgwhite/d55468ecac4e9a5e09f8b7e18b155de2 to your computer and use it in GitHub Desktop.
Confirms and Prompts with Tasks
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 { task, waitForProperty, timeout } from 'ember-concurrency'; | |
const promptTask = task({ | |
answer: undefined, | |
* perform() { | |
yield waitForProperty(this, 'answer', a => a !== undefined); | |
return this.answer; | |
} | |
}); | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
main: task(function * () { | |
let confirmed = yield this.confirm.perform(); | |
if (!confirmed) { | |
return; | |
} | |
let name = yield this.promptForName.perform(); | |
yield this.work.perform(name); | |
}), | |
confirm: promptTask, | |
promptForName: promptTask, | |
work: task({ | |
name: null, | |
* perform(name) { | |
this.set('name', name); | |
yield timeout(3000); | |
} | |
}) | |
}); |
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
@keyframes fade { | |
from { | |
opacity: 1; | |
} | |
to { | |
opacity: 0; | |
} | |
} | |
.pulse { | |
animation: 0.5s infinite alternate fade; | |
} |
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.15.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.4.3", | |
"ember-template-compiler": "3.4.3", | |
"ember-testing": "3.4.3" | |
}, | |
"addons": { | |
"ember-data": "3.4.2", | |
"ember-concurrency": "0.8.19" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment