C
C#4mo ago
CrosRoad95

Blazor rerender

Can i somehow make blazor rerender when property change automatically whereever property change? I don't want to add manually "StateHasChanged"
public class Foo
{
private int _a;
public int A
{
get => _a; set
{
_a = value;
AChanged.InvokeAsync(value);
}
}
public EventCallback<int> AChanged { get; set; }
}
public class Foo
{
private int _a;
public int A
{
get => _a; set
{
_a = value;
AChanged.InvokeAsync(value);
}
}
public EventCallback<int> AChanged { get; set; }
}
then i want to render it:
Foo = @foo.A
Foo = @foo.A
and make it automatically rerender when property "A" changed
var _ = Task.Run(async () =>
{
while (true)
{
await Task.Delay(500);
foo.A++;
}
});
var _ = Task.Run(async () =>
{
while (true)
{
await Task.Delay(500);
foo.A++;
}
});
Or maybe i need to wrap it somehow into a component? but i'm not sure if it's good idea? Foo = <Property>@foo.A</Property>
1 Reply
CrosRoad95
CrosRoad954mo ago
bump?