Working with EmberJS and EmberData

Lately, in working on an upcoming project, I have chosen EmberJS as my front-end framework. I was drawn in by the promise of Ember, and their enthusiastic team, as well as their goal of building “ambitious” web applications.

EmberJS is rails-y in that it places importance on “convention over configuration” and does a lot of “magic” for you behind the scenes to get you up and running.

I’ve been having a bear of a time with Ember, and figured I might be able to clear (or at least offer hints) on some of the stumbling blocks I’ve run into lately.

  1. Models not being loaded at display time.

Turns out this is a well-known problem (and evidently intended behaviour), but the fix is to use .isLoaded and/or .isUpdating (for Array-based models) to detect when the model is ready to be displayed (not without problems though).

Check this github issue out for more information:

https://github.com/emberjs/ember.js/issues/1876

  1. All properties coming in as undefined when using an Ember model to proxy another JS object (for example a File object).

The fix here is to manually (and pain-stakingly) craft a new objects with the important bits of the other JS object copied over. References don’t seem to be honored in the store, so all properties that are important must be extracted (it seems).

So when I needed to make a file, my code ended up looking like this:

`Lately, in working on an upcoming project, I have chosen EmberJS as my front-end framework. I was drawn in by the promise of Ember, and their enthusiastic team, as well as their goal of building “ambitious” web applications.

EmberJS is rails-y in that it places importance on “convention over configuration” and does a lot of “magic” for you behind the scenes to get you up and running.

I’ve been having a bear of a time with Ember, and figured I might be able to clear (or at least offer hints) on some of the stumbling blocks I’ve run into lately.

  1. Models not being loaded at display time.

Turns out this is a well-known problem (and evidently intended behaviour), but the fix is to use .isLoaded and/or .isUpdating (for Array-based models) to detect when the model is ready to be displayed (not without problems though).

Check this github issue out for more information:

https://github.com/emberjs/ember.js/issues/1876

  1. All properties coming in as undefined when using an Ember model to proxy another JS object (for example a File object).

The fix here is to manually (and pain-stakingly) craft a new objects with the important bits of the other JS object copied over. References don’t seem to be honored in the store, so all properties that are important must be extracted (it seems).

So when I needed to make a file, my code ended up looking like this:

`

It looks like EmberData has it’s warts (though the rest of Ember seems quite well-built, or at least predictable)… Finding myself re-considering using Ember at this point (angular seems like a much more trustworthy framework…), but I think I’ll continue with Ember for at least a little bit, give it a fair shake.