jeudi 26 février 2015

What is the proper way in ember to use scheduleOnce that is test friendly?

Not too uncommon we'll need to schedule an update after rendering completes in reaction to a property change. Here is an example



page_changed: function() {
Ember.run.scheduleOnce('afterRender', this, this.scroll);
}.observes('current_page')


This doesn't work for testing since there is no runloop at the time scheduleOnce is called. We can simply wrap scheduleOnce in an Ember.run



page_changed: function() {
Ember.run(function() {
Ember.run.scheduleOnce('afterRender', that, that.scroll);
});
).observes('current_page')


..but I'm being told that's not the right way to go about it. I thought I'd reach out and get some other ideas.


For reference here is the issue that I opened up in ember.js#10536





Aucun commentaire:

Enregistrer un commentaire