Angular array of considerable size

Dealing with a massive array of 30,000 items can be quite daunting, especially when it comes in as a stream using grpc-web. Currently, I'm fetching the data from grpc.client() and populating an array before displaying it using *ngFor. However, I've noticed that this approach is causing some lag and slowness. Is there a more efficient way to showcase this data? I was considering utilizing an Observable array and the async pipe for better performance, but I'm unsure about how to implement it and whether it will actually make a difference.

Below is a snippet of the code:

book.component.ts

queryBooks() {
const client = grpc.client(BookService.QueryBooks, {
  host: host,
});
client.onHeaders((headers: grpc.Metadata) => {
  // console.log("queryBooks.onHeaders", headers);
});
client.onMessage((message: Book) => {
 this.books.push(message.toObject())
});
client.onEnd((code: grpc.Code, msg: string, trailers: grpc.Metadata) => {
  trailers :', trailers);
});
client.start();
client.send(queryBooksRequest);

}

While I'm uncertain whether switching to observables will eliminate the sluggishness, the current setup is proving to be very slow.

Answer №1

One possible solution, as recommended by @Ploppy, is to utilize the data table feature provided by Angular Material CDK.

By doing so, you can reduce the number of elements present in the DOM, leading to a noticeable improvement in rendering speed.

Answer №2

My suggestion would be to consider implementing pagination. If server-side implementation is not feasible, client-side pagination can be a viable option. With problems involving 30,000 items, the use of pagination will help avoid generating an excessive amount of HTML elements.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Parallel Execution Issue with RxJS Observable forkJoin

Struggling to understand why my requests aren't executing concurrently with the following code. As a newcomer to RxJS and observables, I would greatly appreciate any guidance on improving this snippet below. Essentially, I am fetching data from a REST ...

Challenge with validating reactive forms

*ngIf not behaving as expected Although my form's primary condition is working flawlessly, I am facing issues with displaying a specific error message. For example, the code *ngIf="PopupForm.get('startdate').errors?.required is not fun ...

Is there a way for me to retrieve a variable from the response of a service that was defined within the same class in Angular 4?

import {Component, OnInit} from '@angular/core'; import {LoginService} from "../../services/login.service"; import {LoginUser} from "../../services/model"; @Component({ selector: 'login-component', templateUrl: './login.component. ...

The combination of Autodesk Forge Viewer and React with TypeScript provides a powerful platform for developing

I'm brand new to React and Typescript, and I have a very basic question. In the viewer documentation, extensions are defined as classes. Is it possible to transform that class into a typescript function? Does that even make sense? For example, take th ...

TypeScript causing issues when multiple selectors are used

Currently, I have a function that allows me to search for HTML elements based on text content: function findElementsByText(text: string): HTMLElement[] { const selectors = 'button' // This conditional statement ensures that an empty text quer ...

Adjusting the height of an Angular CDK virtual scroll viewport based on dynamic needs

Currently, I am developing an Angular table with the cdk Virtual Scroll feature. Is there a method to adjust the scroll viewport's height dynamically? While the standard style property works, I am encountering difficulties setting the value using ngSt ...

Error in Angular 2.0 final version: Unable to access the 'injector' property of null object

Upon transitioning from Angular 2 RC5 to 2.0 Final, I've encountered some errors while running my tests. It's puzzling me as to what could be causing this issue. TypeError: Cannot read property 'injector' of null at TestBed._create ...

Troubleshooting CORS policy problems in an Ionic Angular application

I am attempting to run the following function in my Ionic Angular application, where cloudFunctionUrl represents a cloud function within my Firebase project: import { HttpClient } from '@angular/common/http'; private http: HttpClient like(post) ...

Is it possible to declare an object literal with optional keys in a Typescript function signature?

I have a .d.ts file similar to this: declare function myfunc(): { something: (err, { req, res, errorInfo, query, pathname, extra }?) => void; }; This declaration states that the function takes two arguments, with the second argument being an optional ...

The type 'Dispatch<any>' cannot be assigned to the type '() => null'. Error code: ts(2322)

While working on my application context, I encountered a typescript error: 'Type 'Dispatch' is not assignable to type '() => null'.ts(2322)'. I am fairly new to typescript and struggling to understand this error. Below is ...

Retrieve the outermost shell of the VUEjs wrapper test-utils

While working on a VueJS test, I encountered an issue where accessing the outermost layer of HTML seemed impossible. No matter what methods I tried, the outermost layer was always ignored. Is there a way to gain access to this outermost layer so that I c ...

Best practices for receiving messages from SQS in Node.js

I am exploring how to implement SQS in a similar manner as RabbitMQ or Kafka, where we usually set up a listener. However, after going through their documentation, I couldn't find any instructions on how to set up a listener for SQS: Currently, I am ...

Unable to pass parameters through the URL in Angular's POST request

Hey there! I'm currently facing an issue with passing a parameter in the POST method URL within an Angular service to construct a URL for fetching data from an API. However, when I try calling it in the component file, I keep getting an error response ...

Angular 12: TypeScript Issue TS2339 - Unable to Locate Property on Type

Whenever I use the code below, I encounter error TS2339: Property 'timestamp' does not exist on type 'LogRepair[]' In the component's HTML file, I am attempting to loop through an array of properties defined in the LogRepair typ ...

Using TypeScript for Routing in Angular

I encountered an error message that says the module 'route' is not available. I'm not sure why this is happening, any thoughts? "Uncaught Error: [$injector:nomod] Module 'route' is not available! You either misspelled the module n ...

Trouble retrieving key value in HTML with Angular and Firebase

When trying to access the key of an object in my database to navigate to a URL based on it, I am finding that the p.$key value is always undefined. service: getAll(){ return this.db.list('/products').valueChanges(); } component: product ...

What could be the reason for the 'tsc' command not functioning in the Git Bash terminal but working perfectly in the command prompt?

I recently installed TypeScript globally on my machine, but I am facing an issue while trying to use it in the git bash terminal. Whenever I run tsc -v, I encounter the following error: C:\Users\itupe\AppData\Roaming\npm/node: l ...

What is the process of personalizing a DaisyUI theme in Tailwind with TypeScript?

I am trying to tailor an existing DaisyUI theme using my tailwind.config.ts file for my Next.js project. Although the DaisyUI documentation only provides examples in JavaScript (text), I want to customize it within my TypeScript environment. Below is a s ...

Tips for personalizing your Compodoc Angular documentation

I've been experimenting with adding extra side navigation menus to the current compodoc documentation. Here's an example of how I tried to accomplish this: menu-wc.js <li class="link"> <a href="dependencies.html" data-type="chapte ...

After receiving a BehaviorSubject, the application was paused to handle multiple outcomes

I am trying to implement BehaviorSubject for handling my login user. I have a user BehaviorSubject that returns an observable. get IsAuthenticated() { return this.user.asObservable().pipe(switchMap(res => { if (res != null) { return of(true); } ...