-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
trackedTask
returns last task value if current task value is null
or undefined
#793
Comments
Is this with v5 or the v6beta? |
It is not, and i think you investigated the bug beautifully! The value getter probably needs to consider if current task is finished before deciding to return lastTask.value or currentTask.value, rather than the existing naiive ?? Excellent find! |
@sergey-zhidkov would you be willing to submit a PR? maybe something to the effect of: get value() {
if (this.return.currentTask?.isFinished) return this.currentTask?.value;
return this.lastTask?.value;
} ? |
It's v5.
Thank you.
I do agree. This is a good way to fix the issue.
I'll be happy to. I'll try to do it by the end of Wednesday. Probably will take some time to write proper tests. |
Fix was merged to main. |
In case if task was called several times and the last returned value was
null
orundefined
, thentrackedTask
returns last (previous) value instead of the correct current one.For example:
Template
Steps to reproduce:
step 1: we pass "0" as value of "myArg" to Child Component =>
myTask
will return "non null non undefined result" value. It will setthis.currentTask
value tonon null non undefined result
at https://github.com/NullVoxPopuli/ember-resources/blob/main/ember-resources/src/util/ember-concurrency.ts#L225.step 2: we pass "1" as value of "myArg" to Child Component =>
myTask
will returnundefined
value. It will setthis.currentTask
value toundefined
.step 3: test that getter returns
non null non undefined result
instead of expectedundefined
.I believe this is happening because of the code in
TaskResource
class https://github.com/NullVoxPopuli/ember-resources/blob/main/ember-resources/src/util/ember-concurrency.ts#L217I wonder if this is expected behavior.
The text was updated successfully, but these errors were encountered: