getoutreach / epf

A framework for keeping your Ember.js apps in sync.
http://epf.io
MIT License
369 stars 33 forks source link

load lazy models only when they have a session #78

Open belluzj opened 11 years ago

belluzj commented 11 years ago

This fix removed lots of errors from my console, and stabilized my app.

It seems that while EPF loads json with sideloaded models, at some point models don't have a session yet but are triggered to load because of observers. Without this fix it just breaks and the lazy model is never resolved. With it, the loading eventually takes place.

ghempton commented 11 years ago

Can you give an example where you hit this for context?

belluzj commented 11 years ago

https://github.com/belluzj/epf_example/commit/94f0429caa4c5468e0e189db421fb90f7d384533

If you are to clone this and launch it (on the lazy-broken branch), please also consider switching to master and try to add a new contact, with an emergency number, and, you will encounter the problem described in my other issue #61

Thanks in advance

denisnazarov commented 10 years ago

Thanks for this pull request, fixed a problem I was having when manually creating models from JSON with belongsTo relationships and merging them with session.merge(model). The session not existing on the belongsTo was throwing errors but this indeed fixes it.

ghempton commented 10 years ago

I am going to put some more work into lazy models soon, but in the mean time I will merge this if I could get a failing test.

belluzj commented 10 years ago

I'm sorry, I'm not working on Ember-based applications anymore, I won't be able to write tests. But you already have a whole failing application at https://github.com/belluzj/epf_example/tree/broken-lazy. (it was broken at the time, I'm not sure it still is).