Skip to content

Instantly share code, notes, and snippets.

@ppcano
Last active December 10, 2015 15:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ppcano/4455029 to your computer and use it in GitHub Desktop.
Save ppcano/4455029 to your computer and use it in GitHub Desktop.
record.loadedData in Run.once async problem
asyncTest("Records loaded multiple times and retrieved in recordArray are ready to send state events", function() {
adapter.findQuery = function(store, type, query, recordArray) {
var self = this;
setTimeout(function() {
Ember.run(function() {
// use different recordArray based on the call
var recordArray = (!!people2) ? people2 : people;
self.didFindQuery(store, type, {
persons: [{
id: 1,
name: "Mickael Ramírez"
}, {
id: 2,
name: "Johny Fontana"
}]
}, recordArray);
});
});
};
var people, people2;
people = store.findQuery(Person, {q: 'bla'});
people.one('didLoad', function() {
people2 = store.findQuery(Person, {q: 'bla2'});
people2.one('didLoad', function() {
start();
expect(3);
equal( people2.get('length'), 2, 'return the elements' );
ok( people2.get('isLoaded'), 'array is loaded' );
var person = people.objectAt(0);
ok( person.get('isLoaded'), 'record is loaded' );
person.deleteRecord();
});
});
});
@ppcano
Copy link
Author

ppcano commented Jan 4, 2013

Uncaught Error: Attempted to handle event loadedData on App.Person:ember244:1 while in state rootState.deleted.uncommitted. Called with {}

Caused by Ember.run.once(record, 'loadedData')

@tomdrn
Copy link

tomdrn commented Jan 11, 2013

Did you find a way to fix this ?

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