RabstackQuery.Blazor
0.3.0
dotnet add package RabstackQuery.Blazor --version 0.3.0
NuGet\Install-Package RabstackQuery.Blazor -Version 0.3.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="RabstackQuery.Blazor" Version="0.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RabstackQuery.Blazor" Version="0.3.0" />
<PackageReference Include="RabstackQuery.Blazor" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add RabstackQuery.Blazor --version 0.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: RabstackQuery.Blazor, 0.3.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package RabstackQuery.Blazor@0.3.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=RabstackQuery.Blazor&version=0.3.0
#tool nuget:?package=RabstackQuery.Blazor&version=0.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
RabStack Query Blazor
Blazor component integration for RabStack Query. Provides a RabstackComponentBase with UseQuery / UseMutation hooks, automatic render coalescing, and component-scoped disposal.
Installation
dotnet add package RabstackQuery.Blazor
Register QueryClient in your DI container:
builder.Services.AddSingleton(new QueryClient(new QueryCache()));
Quick Start
@inherits RabstackComponentBase
@inject IWeatherApi Api
@if (_forecast.IsLoading)
{
<p>Loading...</p>
}
else if (_forecast.IsError)
{
<p class="text-danger">@_forecast.Error?.Message</p>
}
else
{
<table>
@foreach (var item in _forecast.Data!)
{
<tr>
<td>@item.Date</td>
<td>@item.Summary</td>
</tr>
}
</table>
}
<button @onclick="() => _forecast.RefetchCommand.Execute(null)">Refresh</button>
@code {
private QueryViewModel<List<WeatherForecast>> _forecast = null!;
protected override void OnInitialized()
{
_forecast = UseQuery(["weather"],
ctx => Api.GetForecastAsync(ctx.CancellationToken));
}
}
Mutations
@code {
private MutationViewModel<Todo, CreateTodoRequest> _createTodo = null!;
protected override void OnInitialized()
{
_createTodo = UseMutation<Todo, CreateTodoRequest>(
async (request, ctx, ct) => await Api.CreateTodoAsync(request, ct),
new MutationCallbacks<Todo, CreateTodoRequest>
{
OnSuccess = (_, _, _) => Client.InvalidateQueries(["todos"])
});
}
}
Features
UseQuerycreates aQueryViewModelthat is automatically subscribed and disposed with the componentUseMutationcreates aMutationViewModelwith the same lifecycle managementUseQueryCollectionforObservableCollection-backed list queriesUseInfiniteQueryfor paginated/infinite scroll queries- Render Coalescing batches multiple property change notifications into a single
StateHasChanged()call per tick - Automatic Disposal of all tracked ViewModels when the component is removed from the render tree
Track/Observefor integrating pre-composed ViewModels that own their own queries
Pre-composed ViewModels
When your component uses a ViewModel class that internally manages multiple queries and mutations:
@code {
private ProjectListViewModel _vm = null!;
protected override void OnInitialized()
{
_vm = Track(new ProjectListViewModel(Client, Api));
Observe(_vm.ProjectsQuery);
Observe(_vm.CreateProjectMutation);
}
}
Documentation
See the GitHub repository for full documentation, architecture guide, and examples.
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Microsoft.AspNetCore.Components.Web (>= 10.0.5)
- RabstackQuery.Mvvm (>= 0.3.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.