0.0.2 • Published 7 years ago
ember-promises-helpers v0.0.2
ember-promises-helpers 
Installation
ember install ember-promises-helpersUsage
await
{{#if (await model.author)}}
{{get (await model.author) 'name'}}
{{else}}
No author!
{{/if}}The await helper also works anywhere, because it's just a Handlebars subexpression. For example, you can pass it to another helper...
{{#each (await model.comments) as |comment|}}
{{comment.author}} wrote {{comment.text}}
{{/each}}Or pass it to a component:
{{twitter-timeline users=(await user.following)}}Or use it by itself:
{{await model.title}}is-pending
Resolves with false if the promise resolved or rejected, otherwise true until the promise resolves or rejects.
{{#if (is-pending promise)}}
<img src="loading.gif"/>
{{else}}
Loaded!
{{/if}}is-rejected
Resolves with true if the promise rejects or fails, false otherwise. Initial value is false until the promise is resolved.
{{#unless (is-pending promise)}}
{{#if (is-rejected promise)}}
rejected!
{{/if}}
{{/unless}}is-fulfilled
Resolves with true if the promise resolved successfully, false otherwise. Initial value is false until the promise is resolved.
{{#unless (is-pending promise)}}
{{#if (is-fulfilled promise)}}
It works!
{{else}}
Oops!
{{/if}}
{{/unless}}promise-all
Uses the Ember.RSVP.all function to create a promise. It also accepts 1..n promises as arguments or an array as first argument.
{{#if (is-pending (promise-all promise1 promise2))}}
<img src="loading.gif"/>
{{else}}
Loaded!
{{/if}}{{#if (is-pending (promise-all promiseArray))}}
<img src="loading.gif"/>
{{else}}
Loaded!
{{/if}}promise-hash
Uses the Ember.RSVP.hash function to create a promise.
{{#if (is-pending (promise-hash foo=promise1 bar=promise2))}}
<img src="loading.gif"/>
{{else}}
Loaded!
{{/if}}