-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix: ReactiveComponentBase creating unnecessary subscriptions #2391
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
Conversation
e5e1cb6 to
0d14ce8
Compare
Codecov Report
@@ Coverage Diff @@
## master #2391 +/- ##
=======================================
Coverage 54.69% 54.69%
=======================================
Files 114 114
Lines 4344 4344
Branches 663 663
=======================================
Hits 2376 2376
Misses 1801 1801
Partials 167 167 Continue to review full report at Codecov.
|
|
We need to have the Please update the description about |
glennawatson
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes as per comment.
moved all subscriptions into firstRender check
| .RefCount(); | ||
|
|
||
| viewModelChanged | ||
| .Skip(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably remove the Skip(1), this makes sense in constructors where the value couldn't be any value but null but in this case it can be.
|
I applied the changes for testing purpose to my project. Unfortunately the fix will break any rerendering of the component from a PropertyChangedEvent. You can verify the problem by using the ReactiveUI Blazor serverside sample and applying the following changes: FetchDataViewModel.cs: FetchDataView.razor: After loading has finished the page will not update. This can be fixed by changing I'm not such a reactive expert that I can judge if this makes sense. |
|
As far I have tested this PR must be fixed, otherwise view updates neither for SPA nor for WASM will work anymore. Please see my comment here: #2377 |
|
We are aware that this is breaking. No packages have been released. This will be resolved this week in a subsequent Pull Request. No need to comment further on this pull request as it is already merged. |
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
What kind of change does this PR introduce?
Relates To: #2377
What is the current behavior?
The current implementation of the
ReactiveComponentBaseis potentially creating unnecessary subscriptions. Currently, we are wiring upthis.WhenAnyValuein theOnAfterRenderoutside thefirstRenderwhich causes additional subscriptions every render.We currently have our logic checking for the first render, doing some subscriptions for state changes, and then doing others outside of that if block. That code is potentially leaking subscriptions. We also do not call that state change correctly in the observable pipeline.
What is the new behavior?
This change moves all subscription logic to inside the
firstRenderif statement. This will reduce the number of subscriptions generated and should reduce leaks.What might this PR break?
ReactiveUI.Blazor
Please check if the PR fulfills these requirements
Other information: