Class RemoteDataSource<TItem>
- Namespace
- BlazOrbit.Components
- Assembly
- BlazOrbit.dll
Delegates each LoadAsync(DataRequest, CancellationToken) call to a user-supplied async provider. Used for server-side paging where the database (or a remote API) resolves the filters / sorts / page and returns the matching slice plus the total filtered count — the host component never sees the full set, so memory stays bounded regardless of how many rows live behind the source.
public sealed class RemoteDataSource<TItem> : IDataCollectionDataSource<TItem>
Type Parameters
TItemRow item type.
- Inheritance
-
objectRemoteDataSource<TItem>
- Implements
-
IDataCollectionDataSource<TItem>
Examples
private readonly RemoteDataSource<Order> _orders = new(async (request, ct) =>
{
OrdersResponse response = await api.QueryAsync(request, ct);
return new DataResult<Order>(response.Items, response.TotalCount);
});
Constructors
RemoteDataSource(Func<DataRequest, CancellationToken, Task<DataResult<TItem>>>)
Constructs a remote source with a cancellation-aware provider.
public RemoteDataSource(Func<DataRequest, CancellationToken, Task<DataResult<TItem>>> provider)
Parameters
providerFunc<DataRequest, CancellationToken, Task<DataResult<TItem>>>Async loader invoked on every LoadAsync(DataRequest, CancellationToken). The token raised when a newer call supersedes this one — long-running implementations should observe it.
RemoteDataSource(Func<DataRequest, Task<DataResult<TItem>>>)
Convenience overload for providers that don't propagate cancellation. Internally adapts to the cancellation-aware delegate.
public RemoteDataSource(Func<DataRequest, Task<DataResult<TItem>>> provider)
Parameters
providerFunc<DataRequest, Task<DataResult<TItem>>>Async loader invoked on every LoadAsync(DataRequest, CancellationToken).
Methods
LoadAsync(DataRequest, CancellationToken)
Loads the slice described by request. Implementations honour
the page / page size, global filter, per-column filters and sort descriptors,
and return both the materialised page and the total row count after filtering
(the host component uses the total to compute pagination — the slice itself
only contains the visible page).
public Task<DataResult<TItem>> LoadAsync(DataRequest request, CancellationToken cancellationToken = default)
Parameters
requestDataRequestUser intent describing the desired slice.
cancellationTokenCancellationTokenToken raised when a newer LoadAsync(DataRequest, CancellationToken) call supersedes this one (typing fast in a column filter, rapid pagination clicks). Long-running implementations should observe the token to avoid leaking work after the host component has moved on.
Returns
- Task<DataResult<TItem>>
Page slice plus total filtered row count.