Created
October 14, 2015 20:38
-
-
Save rondale-sc/8e81f9dfcacc47cb4752 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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