ember-concurrency icon indicating copy to clipboard operation
ember-concurrency copied to clipboard

lastSuccessful updates even though it hasn't actually changed yet

Open Techn1x opened this issue 3 years ago • 1 comments

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 avatar Jun 10 '22 08:06 Techn1x

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.

Techn1x avatar Jun 10 '22 08:06 Techn1x