Skip to content

Instantly share code, notes, and snippets.

@akatov
Last active March 22, 2017 18:40
Show Gist options
  • Save akatov/128e46ea828861eb512e1b55ed403776 to your computer and use it in GitHub Desktop.
Save akatov/128e46ea828861eb512e1b55ed403776 to your computer and use it in GitHub Desktop.
Promise Array Experiments
import Ember from 'ember';
import DS from 'ember-data';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
actions: {
fire() {
window.resolve('hai');
}
}
});
window.promise = new Ember.RSVP.Promise((resolve) => {
window.resolve = resolve;
// will be resolved manually
});
window.promises = Ember.RSVP.all([window.promise]);
window.promiseArray = DS.PromiseArray.create({ promise: window.promises });
window.logPromiseArray = function() {
console.log('promiseArray ', window.promiseArray)
console.log('promiseArray []', window.promiseArray.toArray())
}
logPromiseArray()
window.promise.then((x) => {
console.log('resolved with', x);
logPromiseArray();
});
window.promiseArray.then((x) => {
console.log('promiseArray resolved with', x);
logPromiseArray();
})
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
<br>
<button {{action "fire"}}>Fire</button>
{
"version": "0.11.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.11.0",
"ember-data": "2.11.0",
"ember-template-compiler": "2.11.0",
"ember-testing": "2.11.0"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment