Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

317
Vistas
Angular 7+ : how can I implement a refresh from api endpoint silently?

I'm looking for some opinions to implement a 'silent' fetch from a given data endpoint.

Currently I have an implementation to fetch data on component init as you would expect

//apiService.ts
getData(params): Promise < Member[] > {
  return this.httpService.doRequest(`${this.baseUrl()}/member`, 'get', convertToQueryParams(params), null);
}


//component.ts
this.apiService
  .getData(params)
  .then((response: any) => {
    const responseData: Member[] = response.data
    this.data = responseData.map(member => new Display(member))
  })
  .catch(e => console.log('error occured while fetching table data. Try again: ', e))

After this I would like to implement a silent refresh on the same getData endpoint which fetches the data every 5 minutes and silently paints the page with new data without user realizing the data was updated. This also means not showing any sort of loading or refresh behavior on the page for this silent fetch.

My organization currently uses angular 7 but we plan to upgrade to angular 12 this year. Any ideas or suggestions would be appreciated.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Since you are working in Angular, you can always use observables. I see you are using a promise but retuning an observable is a quick fix. You can use the timer function which will do exactly what you want: https://www.learnrxjs.io/learn-rxjs/operators/creation/timer

Another option is to use setInterval and save its reference so you can cancel it when a component is destroyed. https://developer.mozilla.org/en-US/docs/Web/API/setInterval

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda