https://github.com/amk221/ember-promise-cps
Computed property macros for working with promises
https://github.com/amk221/ember-promise-cps
computed-properties ember promises
Last synced: about 2 months ago
JSON representation
Computed property macros for working with promises
- Host: GitHub
- URL: https://github.com/amk221/ember-promise-cps
- Owner: amk221
- License: mit
- Created: 2017-01-29T21:10:45.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-04-03T10:40:54.000Z (about 9 years ago)
- Last Synced: 2025-08-09T05:31:26.949Z (10 months ago)
- Topics: computed-properties, ember, promises
- Language: JavaScript
- Size: 82 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# ember-promise-cps
This Ember addon provides you with utils and computed property macros to aid with common problems when working with promises in components.
1. Subsequent promises take priorty over 'old' promises
(You're usually only ever bothered about the result from the most recent promise)
2. Setting the result of the promise on the component when the component may since have been destroyed will error.
## No longer maintained
Please use [http://ember-concurrency.com](http://ember-concurrency.com) instead
## Example
```handlebars
{{! application.hbs }}
{{items-list items-promise=promiseForItems}}
```
```javascript
// items-list/component.js
import { promiseObject } from 'ember-promise-cps/macros';
export default Component.extend({
items: promiseArray('items-promise')
});
```
```handlebars
{{! items-list/template.hbs }}
{{#if items.isPending}}
Loading items
{{else if items.isRejected}}
Unable to display items: {{items.reason}}
{{else if items.isFulfilled}}
{{#each items as |item|}}
...
{{/each}}
{{/if}}
```
### Available utils/macros
* Utils
* `promiseObject({ foo: 'bar' })`
* `promiseArray([ 'foo', 'bar' ])`
* Macros
* `promiseObject('myObject')`
* `promiseArray('myArray')`
### Installation
```
ember install ember-promise-cps
```