Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

496
Visualizações
how to put interval on retry call in Angular

The following call makes like around 800 connection in 5 seconds, I want to make a connection every 5 seconds to reduce the number of connections. If I put retry(5) after 5 attempts it will stop and I may not have a successful result in 5 tries, thats why I need a time here I think.

  this.http.get(`api`)
 .pipe(retry())
 .subscribe(s=>{
   //result
  },error=>(error));

I don't know where should I put interval actually as far as I know it should come after subscribe but it seems this approach is not the right way.

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

You'd need to use the retryWhen operator with delay operator. Try the following

import { retryWhen, delay } from 'rxjs/operators';

this.http.get(`api`).pipe(
  retryWhen(error => error.pipe(delay(5000))
).subscribe(
  s => { 
    // result
  },
  error => {
    // handle error
  }
);
over 4 years ago · Santiago Trujillo Relatório

0

I have used similar functionality in one of my angualr application and worked out this way. Check if this helps.

this.subscription = interval(5000).subscribe(x => {
// API call goes here...
       
});

This code continously executes for every 5 seconds once and if you want to stop the timer then

this.subscription.unsubscribe();
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda