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

154
Vistas
What is a good way to handle server side pagination and loading the data to dropdown?

I am working on an Angular application. It fetches data from ASP.NET Core API, where server side pagination is implemented. In Angular application I have implemented state manager - NGXS.

I need to fetch the API data and display it inside dropdown and table. I have some ideas on doing that and I would like to receive some feedback.

This is what a minified version of my project looks like:

That is one of my StateModels, it stores a list of fetched services (entity) inside a wrapper

export class ServicesStateModel {
    services: PaginatedList<Service[]>; 
}

And this is the Action for fetching the services.

 @Action(FetchServices, { cancelUncompleted: true })
  fetchServices({ getState, setState }: StateContext<ServicesStateModel>, { pageNumber, pageSize }: FetchServices): Observable<ApiResponsePaginated<Service[]>> {
    return this.servicesApiService.getServices(pageNumber, pageSize).pipe(
      tap((result: ApiResponsePaginated<Service[]>) => {
        const { data } = result;
        if (data) {
          const state = getState();
          setState({ ...state, services: new PaginatedList<Service[]>(data.items,data.pageIndex, data.totalPages, data.totalCount), });
        }
      })
    )
  }
  1. Every time I change the page inside the table, FetchServices action is dispatched, resulting in a new API call, and its result being saved to the state model and displayed. Is that correct or should I perhaps fetch more than one page at once? Should I save already displayed pages inside a state, so when I switch back to the previous page I avoid another API call, and get it directly from state or is that an overkill?

  2. Every time I open a component where the table is displayed with no pagination implemented, I dispatch some Fetch action. It results in API call on every component enter. Should I avoid that and store the data in state and call API only on page refresh ?

Thank you for your time.

about 4 years ago · Santiago Gelvez
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