you don't say if this is client (WASM) or server blazor. I assume, its server, and the delay is sending the list up the signal/r connection.
if using server, then only store the key in local storage, and store the data is server persistent store.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have a data in localStorage I catch them by OnInitializedAsync method in mainLayout component and pass them to many component but it spends a lot of time how to inhance it ? this is my code
Notes: the number of Items in list which I catch from local storage is more than 3000, the method spend more than 15000 milliseconds, and I am using chrome browser
<div class="page">
<NavMenu/>
<CascadingValue Value="this">
<main class="margin-page container px-0">
<article class="px-1">
@Body
</article>
</main>
</CascadingValue>
</div>
@code
{
public List<Product> product { get; set; } = new List<Product>();
Navbar navbar { get; set; }
protected async override Task OnInitializedAsync()
{
await GetProducts();
await base.OnInitializedAsync();
}
public async Task GetProducts()
{
var result = await _localStorageService.GetItem<List<Product>>("Items");
if (result is not null)
{
product = result;
}
}
}
you don't say if this is client (WASM) or server blazor. I assume, its server, and the delay is sending the list up the signal/r connection.
if using server, then only store the key in local storage, and store the data is server persistent store.
Hi @Haneen Al-fakhry
the number of Items in list which I catch from local storage is more than 3000, the method spend more than 15000 milliseconds, and I am using chrome browser
Try to use pagination to display data, such as 50 records per page, it will reduce the data query time.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards,
Dillion