Skip to content

Instantly share code, notes, and snippets.

@mszoernyi
Last active August 29, 2015 14:22
Show Gist options
  • Save mszoernyi/314f4e16a4ed1a38c71f to your computer and use it in GitHub Desktop.
Save mszoernyi/314f4e16a4ed1a38c71f to your computer and use it in GitHub Desktop.
simulate store.find for non ember models
_findCountries: ->
isoCodes = Ember.Object.createWithMixins(IsoCodes)
countries = (Ember.Object.create({ id: code, name: name }) for code, name of isoCodes.isoCountries)
promise = Ember.RSVP.Promise.resolve(countries)
promiseArray = Ember.ArrayProxy.extend(Ember.PromiseProxyMixin)
promiseArray.create({ promise: promise })
@mszoernyi
Copy link
Author

I've a list of countries which are not stored in the store and so there is no 'real' ember-data model for it.

This list is used for a selectize box which is rendered dynamically and all other models are fetched from the store via .find. What I'm trying to archive is to return the same structure as I get with store.find(). The result needs to be a promise and it has to have a content.

this returns me an array not an object with a content attribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment