-
-
Notifications
You must be signed in to change notification settings - Fork 28
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
feature: Improved IDisposable Handling, Possibility to Change Validation Rules Dynamically #115
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov Report
@@ Coverage Diff @@
## main #115 +/- ##
==========================================
+ Coverage 52.73% 54.25% +1.51%
==========================================
Files 16 16
Lines 895 894 -1
==========================================
+ Hits 472 485 +13
+ Misses 423 409 -14
Continue to review full report at Codecov.
|
glennawatson
approved these changes
Oct 13, 2020
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce?
This PR allows
IValidationComponent
s to be detached from aValidationContext
.What is the current behavior?
As described in #71, currently there is no way to detach an
IValidationComponent
if it is attached to aValidationContext
. Although it is possible to writeWhenAnyValue
-basedValidationRule
s that respect the observable and mutable state of a validated view model, sometimes it may be easier to just remove and dispose of a specificIValidationComponent
.Currently there is no way to dispose of a
BasePropertyValidation
and of aModelObservableValidation
, see https://github.com/reactiveui/ReactiveUI.Validation/blob/main/src/ReactiveUI.Validation/Extensions/ValidatableViewModelExtensions.cs#L58 If we call theValidationRule()
extension method, a new instance of a disposableIValidationComponent
is created and attached to theValidationContext
. Notably, the disposable validation component is never disposed of. Also, currently, there is no way to dispose of the validation component manually, theIValidationComponent
interface doesn't implementIDisposable
, and theValidationHelper
doesn't dispose of the underlyingIValidationComponent
.What is the new behavior?
Now, if we dispose of the
ValidationHelper
that is returned by a call toValidationRule
, it will dispose of an underlyingBasePropertyValidation
or aModelObservableValidation
automatically. Also, it will detach theIValidationComponent
from theValidationContext
before disposal. Also, it is now possible to detach any validation components manually from the validation context. We are now accessing theReadOnlyObservableCollection<IValidationComponent>
in a reactive fashion both in ourINotifyDataErrorInfo
implementation, and in theBindValidation
extension method. This allows puttingValidationRule
s into aWhenActivated
block e.g.What might this PR break?
Hopefully nothing.
Please check if the PR fulfills these requirements