Skip to content

Instantly share code, notes, and snippets.

@rondale-sc
Created October 14, 2015 20:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rondale-sc/8e81f9dfcacc47cb4752 to your computer and use it in GitHub Desktop.
Save rondale-sc/8e81f9dfcacc47cb4752 to your computer and use it in GitHub Desktop.
import Ember from 'ember';
const PromisableArrayProxy = Ember.ArrayProxy.extend(Ember.PromiseProxyMixin);
export default function(...args) {
const fn = args.pop();
const dependentKeys = args.slice();
return Ember.computed(...dependentKeys, function() {
const promise = fn.apply(this);
return PromisableArrayProxy.create({
promise: Ember.RSVP.resolve(promise)
});
});
}
// invoke like
//
// myArray: asyncArrayProxy('depkeys', function(){
// return this.store.findAll('posts');
// });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment