Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Blazor StateHasChanged not firing on ViewModel change #2303

Merged
merged 1 commit into from Jan 6, 2020

Conversation

@glennawatson
Copy link
Contributor

glennawatson commented Jan 6, 2020

Fixes #2298 where the view model property being changed doesn't trigger a state refresh.

@glennawatson glennawatson requested a review from reactiveui/core-team as a code owner Jan 6, 2020
@codecov

This comment has been minimized.

Copy link

codecov bot commented Jan 6, 2020

Codecov Report

Merging #2303 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2303   +/-   ##
=======================================
  Coverage   55.32%   55.32%           
=======================================
  Files         113      113           
  Lines        4334     4334           
  Branches      660      660           
=======================================
  Hits         2398     2398           
  Misses       1771     1771           
  Partials      165      165

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 908579d...796fd94. Read the comment docs.

@glennawatson glennawatson merged commit 8d7f45d into master Jan 6, 2020
4 checks passed
4 checks passed
ReactiveUI-CI Build #11.1.6+73a925e329 succeeded
Details
codecov/patch Coverage not affected when comparing 908579d...796fd94
Details
codecov/project 55.32% remains the same compared to 908579d
Details
license/cla All CLA requirements met.
Details
@glennawatson glennawatson deleted the glennawatson-fix-blazor branch Jan 6, 2020
@@ -37,7 +37,8 @@ public class ReactiveComponentBase<T> : ComponentBase, IViewFor<T>, INotifyPrope
/// </summary>
public ReactiveComponentBase()
{
var propertyChangedObservable = this.WhenAnyValue(x => x.ViewModel)
this.WhenAnyValue(x => x.ViewModel).Subscribe(_ => StateHasChanged());
var viewModelsPropertyChanged = this.WhenAnyValue(x => x.ViewModel)

This comment has been minimized.

Copy link
@michaelstonis

michaelstonis Jan 6, 2020

Contributor

Doesn't this still need a check for null? When I was testing this out, part of the issue is that the event chaining failed when the ViewModel was null.

Adding a .Where(x => x != null) or a default check should resolve that.

This comment has been minimized.

Copy link
@limefrogyank

limefrogyank Jan 6, 2020

Contributor

or a .WhereNotNull()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.