machty / ember-concurrency

ember-concurrency is an Ember Addon that enables you to write concise, worry-free, cancelable, restartable, asynchronous tasks.
http://ember-concurrency.com
MIT License
691 stars 155 forks source link

lastSuccessful updates even though it hasn't actually changed yet #467

Open Techn1x opened 2 years ago

Techn1x commented 2 years ago

I'm on Ember 3.28 so everything is autotracked. I noticed that when you perform() a task, it updates lastSuccessful twice. Or at least something is causing it to update.

get lastSuccessful() {
  return this.taskDef.lastSuccessful
}

With a getter like this, it seems as though it is being called recalculated immediately when the perform() is called, and then again after that new task is successful. In theory, the lastSuccessful property should never change as soon as perform() is called - it should only ever need to change & cause tracking updates when a perform() has finished and been successful

My use case is that I have a table like this, and each time the perform is called to go get a new value, the rows get rendered twice

{{#each this.taskDef.lastSuccessful.value as |row|}}
  <tr>
    // each time taskDef is performed, I get rendered twice :(
  </tr>
{{/each}}

I think this is a bug, but let me know if I'm doing things wrong.

Techn1x commented 2 years ago

I also tried using the @lastValue('taskDef') decorator hoping it did some caching magic, but no luck there.

I should mention, it's not just lastSuccessful - other properties like lastComplete exhibit similar behaviour, so I suspect it's something deeper.