[Question] What is the correct way to call StateHasChanged when a collection changes (Blazor)? #3230
Unanswered
geometrikal
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm using ReactiveUI.Blazor to implement MVVM in a Blazor WASM application.
View models are made available using the built-in DI. They inherit from
ReactiveObject
and I'm usingSourceList
for the observable collection, e.g.public SourceList<int> MyListOfNumbers {get; set;} = new()
The views inherit from
ReactiveInjectableComponentBase<TViewModel>
.If any properties are changed in the view model the component will automatically update. However if the
SourceList
changes, it does not. What is the correct way to watch forSourceList
changes and update the component? Currently I do the following insideOnInitialised
in the view:Is this correct?
(Can someone alse explain what is being done inside
OnAfterRender
inReactiveInjectableComponentBase
to hook up the properties toStateHasChanged
)Beta Was this translation helpful? Give feedback.
All reactions