Skip to content

Instantly share code, notes, and snippets.

@consideRatio
Created January 6, 2014 21:26
Show Gist options
  • Save consideRatio/8290103 to your computer and use it in GitHub Desktop.
Save consideRatio/8290103 to your computer and use it in GitHub Desktop.
CONSOLE_LOG:
1
2
RETURNING
3
4
PROBLEM & Question:
Ember does not render anything until passing point 4, that takes considerable time, can i get it to render without waiting?
SpeedMind.SourceRoute = Ember.Route.extend({
model: function (params) {
var id = params.source_id;
var store = this.get('store');
var scope = this;
var source = store.getById('source', id);
if (source)
return source;
var promise = new Ember.RSVP.Promise(function(resolve, reject){
console.log(1);
var something = SpeedMind.getDoc(id).then(function(response) {
console.log(3);
store.pushPayload(response);
console.log(4);
source = store.getById('source', id);
return source
});
console.log(2);
resolve(something);
});
console.log("RETURNING");
return promise;
},
renderTemplate: function() {
this.render();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment