Caching remote data in Local Storage with EmberData

Just to “bump” this thread up a little, because it was one of the top results when I researched solutions for ember local cache of restful api, etc.: Dan Gebhardt seems to do a bloody good job with Orbit.js and its integration into Ember: https://github.com/orbitjs/ember-orbit Orbit is a standalone library for coordinating access to data … Read more

How should errors be handled when using the Ember.js Data RESTAdapter?

This weekend I was trying to figure the same thing out. Going off what Luke said, I took a closer look at the ember-data source for the latest commit (Dec 11). TLDR; to handle ember-data update/create errors, simply define becameError() and becameInvalid(errors) on your DS.Model instance. The cascade triggered by the RESTadapter’s AJAX error callback … Read more

Ember.js: Reloading a .hasMany relationship given through “links” in payload

DS.Model.reopen({ reloadLink: function (linkKey) { if ($.isArray(linkKey)) { var promises = []; for (var i = 0; i < linkKey.length; i++) { promises.push(this.reloadLink(linkKey[i])); } return Em.RSVP.all(promises); } else { var rel = this._relationships[linkKey]; if (rel) { if (rel.reload) { return rel.reload(); } else if (rel.fetchLink) { return rel.fetchLink(); } } } } }); Example: model: … Read more

Ember CLI testing complicated model relationships

If you are using Ember default ‘Ember-QUnit’ then you have to list all the models in needs. But there is an alternative for testing which I am using i.e. ember-data-factory-guy. This is used to create factory instead of fixture data when testing Model, component, controller etc. You can go through it. https://github.com/danielspaniel/ember-data-factory-guy

infinite scroll with ember.js (lazy loading)

I’ve implemented an infinite scroll mechanism at the GitHub Dashboard project, I’m currently developing. The feature is added in commit 68d1728. The basic idea is to have a LoadMoreView which invokes the loadMore method on the controller every time the view is visible on the current viewport. I’m using the jQuery plugin inview for this. … Read more