MartinMalinda / vue-concurrency

A library for encapsulating asynchronous operations and managing concurrency for Vue and Composition API.

Home Page:https://vue-concurrency.netlify.app/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to retry Tasks?

BenJackGill opened this issue · comments

I want to create a Task that will retry x number of times if a specific kind of error is thrown.

But I can't figure out how to retry the call based on it's error message. I want to retry the call a limited number of times if the error is INVALID_OAUTH. Otherwise just throw the error like normal.

Do you have any examples I can use as inspiration?

My stupid brain can't figure it out.

For example:

const getZohoDeskTicketByIdTask = useTask(function* (signal, ticketId: string) {
  const ticket: string = yield getZohoDeskTicketById({
    ticketId: ticketId,
  });
  // If the above yield returns an error of 'INVALID_OAUTH' it should retry X number of times before failing. If the error is anything else, throw it like normal.
  return ticket;
});

const ticket = await getZohoDeskTicketByIdTask.perform('12345');

Please disgrard. I took another route.

I tried to delete this issue but I couldn't. Feel free to delete it if you can.