Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This may depend on how fast the progress tasks are completing. I am currently doing this in a <code>ProgressView</code> using a corresponding model with a <code>progress</code> property that is updated.</p> <p>When the model changes the progress bar updates as the view is bound to this model. <a href="http://jsbin.com/iluwan/2" rel="nofollow">Here's</a> how I am doing this. The actual value in the model is updated with events from other pieces, here a setInterval is used.</p> <h2>Edit: after question updated with jsbin</h2> <p>The <code>this.set('progress')</code> calls are collapsed into a single call with the last value set by the Ember runloop. This is an important performance optimization, that helps prevents bindings from firing only once for a given property per runloop.</p> <p>To force the <code>progress</code> calls to be queued you would need to wrap it in some sort of interval, or use <code>Ember.run.scheduleOnce</code>. ie:- increment a counter of steps immediately, then count down slower with the interval or <code>scheduleOnce</code>.</p> <p>Here's an example <code>ProgressStepper</code>. You specify the <code>totalSteps</code> at instantiation time, and call <code>next</code> when a step completes. The progress bar can be bound to it's <code>progress</code> property. It uses <code>scheduleOnce</code>, you can tick slower with setInterval of say 100ms.</p> <pre><code>App.ProgressStepper = Em.Object.extend({ totalSteps: 10, currentStep: 0, progress: 0, complete: Ember.K(), pending: 0, isOnRunloop: false, next: function() { this.set('pending', this.get('pending') + 1); if (!this.get('isOnRunLoop')) { this.set('isOnRunLoop', true); this.enqueue(); } }, enqueue: function() { // ticking on the runloop gives better performance // as it doesn't use additional timers Ember.run.scheduleOnce('afterRender', this, 'onNext'); // use this is if you want to tick slower //setTimeout(this.onNext.bind(this), 100); }, onNext: function() { this.nextStep(); if (this.hasPending()) { this.enqueue(); } else { this.set('isOnRunLoop', false); } }, hasPending: function() { return this.get('pending') &gt; 0; }, nextStep: function() { this.set('pending', this.get('pending') - 1); var currentStep = this.get('currentStep'); var totalSteps = this.get('totalSteps'); currentStep++; if (currentStep &lt;= totalSteps) { this.set('currentStep', currentStep); this.updateProgress(); if (currentStep == totalSteps) { Ember.run.scheduleOnce('afterRender', this, 'complete'); } } }, updateProgress: function() { var progress = this.get('currentStep') / this.get('totalSteps') * 100; this.set('progress', progress); } }); </code></pre> <p>Here's an updated <a href="http://jsbin.com/epayox/1/" rel="nofollow">jsbin</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload