I tried second example here https://learn.microsoft.com/en-us/aspnet/core/blazor/components/virtualization?view=aspnetcore-9.0
I tried to implement endless scrolling using native Blazor, without javascript or other libraries.
<Virtualize ItemsProvider="itemsProvider" OverscanCount="10" Context="cxt">ItemsProvider demands an ItemsProviderDelegate, I declared one and the context, cxt I'm using to acceses itemsProvider.Name as cxt.Name and etc...
ItemsProviderDelegate<ProductDto>? itemsProvider;As I scroll the Virtualize I want at the end of the scroll or before at the middle to trigger an LoadVisibleProducts a function to load more products. The outdated examples of 4 years ago on the internet are not working, documentation is outdated. The function:
private async ValueTask<ItemsProviderResult<ProductDto>> LoadVisibleProducts(ItemsProviderRequest request){ var magar = await ProductApi.GetProductsAsync1(request.StartIndex, request.Count); foreach (var cartItem in CartService.Items) { var product = magar.FirstOrDefault(p => p.Id == cartItem.ProductId); if (product != null) { product.Quantity = cartItem.Quantity; } } return new ItemsProviderResult<ProductDto>(magar, magar.Length);}I override OnInitialized and call the function like this
itemsProvider = request => LoadVisibleProducts(request);I used breakpoints inside the function LoadVisibleProducts. It doesn't enter there.
How should I call the function? Is the intended usage still possible? If the question is not clear and the source code is needed I'll provide it in 12h, I worked for 10h, and I need to sleep!