First of all, I'm using Firebase, or more specifically, EmberFire. I'm making a simple chat app and everything was going along swimmingly, until I attempted to limit the number of posts that are first fetched.
I had
// routes/index.js
import Ember from 'ember';
export default Ember.Route.extend({
model: function() {
return this.store.find('message');
}
});
and I changed it to
// routes/index.js
import Ember from 'ember';
export default Ember.Route.extend({
model: function() {
return this.store.find('message',{
orderBy: 'timestamp',
limitToLast: 10
});
}
});
With the former, as soon as new messages were posted, they would show up in my other browsers. With the later, I have to refresh the page for them to show up. I believe this is because the first returns a DS.RecordArray
while the second return a DS.AdapterPopulatedRecordArray
, but I'm not sure how to fix it.
How can I fetch the last 10 messages, but still have new messages automatically added to the model?
DEBUG: -------------------------------
DEBUG: Ember : 1.11.1
DEBUG: Ember Data : 1.0.0-beta.16.1
DEBUG: Firebase : 2.2.5
DEBUG: EmberFire : 1.4.4
DEBUG: jQuery : 1.11.3
DEBUG: -------------------------------
Aucun commentaire:
Enregistrer un commentaire