Last active
December 10, 2015 15:29
-
-
Save ppcano/4455029 to your computer and use it in GitHub Desktop.
record.loadedData in Run.once async problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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')