This Ember addon provides you with a computed property macros to aid with common problems when passing promises into components:
- Subsequent promises take priorty over 'old' promises
(You're usually only ever bothered about the result from the most recent promise) - Setting the result of the promise on the component when the component may since have been destroyed.
// items-list/component.js
import { promiseObject } from 'ember-promise-cps/macros';
export default Component.extend({
items: promiseArray('items-promise')
});
- Utils
promiseObject({ foo: 'bar' })
promiseArray([ 'foo', 'bar' ])
- Macros
promiseObject('myObject')
promiseArray('myArray')
- If you use helpers to resolve the promise inside your template like:
...then the downside is you don't _also_ have the ability to base more computed properties on the result of that promise in the component itself. (It's more useful to resolve the promise in the component, and let your template read the properties rather than the other way around. It also leads to simpler templates).
- If you need something more substantial, see: http://ember-concurrency.com/
ember install ember-promise-cps