Skip to content
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

an attempt at adding retry() to trackedTask #119

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

BoussonKarel
Copy link
Contributor

@BoussonKarel BoussonKarel commented Sep 18, 2024

trackedFunction has a retry option, but the trackedTask doesn't have this (yet).

Here is an attempt at adding retry to the trackedTask.

Copy link

vercel bot commented Sep 18, 2024

@BoussonKarel is attempting to deploy a commit to the universal-ember Team on Vercel.

A member of the Team first needs to authorize it.

@@ -193,11 +196,22 @@ export class State<Args extends any[], Return, LocalTask extends TaskIsh<Args, R
return this.lastTask?.value;
}

[RUN] = (positional: Args) => {
[RUN] = () => {
let args = this[THUNK] || DEFAULT_THUNK;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of doing this[THUNK] || DEFAULT_THUNK here, could we move it to the constructor.

this way, we can access the args directly in here (still invoking normalizeThunk as you have it though).

@@ -69,7 +65,7 @@ export function task<

registerDestructor(state, () => state[TASK].cancelAll());

return destroyable as unknown as TaskInstance<Return>;
return destroyable as unknown as TaskInstance<Return> & { retry: () => void };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know in discord you said you might want to do the type differently -- but I think this is fine <3

@@ -195,6 +195,72 @@ module('useTask', function () {
assert.true(foo.search.isFinished);
assert.false(foo.search.isRunning);
});

test('it runs again when calling retry()', async function (assert) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a testing technique that might help here (and/or in a rendering test)
is using assert.step('name of thing') and then at various intervals calling assert.verifySteps([expected steps]) -- this way you don't necessarily need to be concerned with the exact values if you don't need to be

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants