Class ObserveQuery<TArg, TResult>
Blazor component to subscribe to a query and re-render when it changes.
public sealed class ObserveQuery<TArg, TResult> : ComponentBase, IComponent, IHandleEvent, IHandleAfterRender, IDisposable
Type Parameters
TArg
TResult
- Inheritance
-
ObserveQuery<TArg, TResult>
- Implements
- Inherited Members
Remarks
This be used standalone, to trigger re-renders and events:
<ObserveQuery Target="query" OnChanged="StateHasChanged" />
Or, it can be used as a wrapper around other components, to automatically re-render only the wrapped content:
<ObserveQuery Target="query">
@* Put content that depends on the query here. *@
</ObserveQuery>
See https://jcparkyn.github.io/phetch/docs/using-query-objects-directly.html for more information.
Properties
ChildContent
[Parameter]
public RenderFragment? ChildContent { get; set; }
Property Value
DetachWhenDisposed
Automatically detach this query when this component is disposed. Only use this when this is
the only component using this query instance, and the ObserveQuery
is not rendered
conditionally. Otherwise, implement IDisposable and call Detach() to detach the query manually.
[Parameter]
public bool DetachWhenDisposed { get; set; }
Property Value
OnChanged
Callback function to call whenever the query state changes. This is usually used to trigger
component re-renders using StateHasChanged
.
[Parameter]
public Action OnChanged { get; set; }
Property Value
OnFailure
Callback function to call when the query fails. This will only be called if this component is still mounted when the query fails. If you make multiple requests at the same time, this will only be called for the last request.
[Parameter]
public Action<QueryFailureEventArgs<TArg>>? OnFailure { get; set; }
Property Value
- Action<QueryFailureEventArgs<TArg>>
OnSuccess
Callback function to call when the query succeeds. This will only be called if this component is still mounted when the query succeeds. If you make multiple requests at the same time, this will only be called for the last request.
[Parameter]
public Action<QuerySuccessEventArgs<TArg, TResult>>? OnSuccess { get; set; }
Property Value
- Action<QuerySuccessEventArgs<TArg, TResult>>
Target
[Parameter]
[EditorRequired]
public IQuery<TArg, TResult>? Target { get; set; }
Property Value
- IQuery<TArg, TResult>
Methods
BuildRenderTree(RenderTreeBuilder)
Renders the component to the supplied RenderTreeBuilder.
protected override void BuildRenderTree(RenderTreeBuilder builder)
Parameters
builder
RenderTreeBuilderA RenderTreeBuilder that will receive the render output.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()