Last active
January 3, 2020 18:51
-
-
Save GendelfLugansk/b5f384a952d6a1d5a8408a7a3e91244d to your computer and use it in GitHub Desktop.
Question 59529650
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 EmberObject, { set } from '@ember/object'; | |
import ArrayProxy from '@ember/array/proxy'; | |
import { Promise, resolve, all } from 'rsvp'; | |
const section = EmberObject.create(); | |
const log = ArrayProxy.create({ content: [] }); | |
export default Ember.Controller.extend({ | |
appName: 'Question 59529650', | |
chainLength: 0, | |
promisesRunning: 0, | |
log, | |
section, | |
someAction() { | |
var section = this.section; | |
var myPendingPromise = section.myPendingPromise || resolve(); | |
myPendingPromise = myPendingPromise.then(() => { | |
return this.myCustomPromise(); | |
}); | |
set(section, 'myPendingPromise', myPendingPromise); | |
this.incrementProperty('chainLength'); | |
}, | |
myCustomPromise() { | |
return new Promise(resolve => { | |
this.incrementProperty('promisesRunning'); | |
this.log.pushObject('Promise started'); | |
setTimeout(() => { | |
this.decrementProperty('chainLength'); | |
this.decrementProperty('promisesRunning'); | |
this.log.pushObject('Promise resolved'); | |
resolve(true) | |
}, 2000); | |
}); | |
}, | |
}); |
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.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" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment