Skip to content

PartCycleTech/ember-computable-promise

Repository files navigation

ember-computable-promise

Usage

In your component.js:

import Ember from 'ember';
import {computablePromise, computablePromiseValue} from 'ember-computable-promise';

export default Ember.Component.extend({
  someValue: 'foo',

  myPromise: computablePromise('someValue', function() {
    let result = this.get('someValue');
    return new Ember.RSVP.Promise( resolve => {
      resolve(result);
    });
  }),

  myResolvedValue: computablePromiseValue('myPromise') // will be 'foo' after myPromise resolves
});

myResolvedValue will be undefined before the promise has fulfilled, and will contain the resolved value after fulfillment.

Now your templates will automatically be compatible with {{myResolvedValue}}

About

Provides a mechanism to create Ember computed properties which watch Promise values

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •