-
Notifications
You must be signed in to change notification settings - Fork 110
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
[New Feature] Add new possible value for ngrxUpdateOn #119
Conversation
Codecov Report
@@ Coverage Diff @@
## master #119 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 116 116
Lines 2180 2184 +4
Branches 408 408
=====================================
+ Hits 2180 2184 +4
Continue to review full report at Codecov.
|
Thank you for this PR. I can see how this feature would be useful. However, I am not so sure about still dispatching the There is also the problem of when to dispatch the Therefore, to prevent confusion I would like you to change the code to simply not dispatch either action if "It is possible to control when view value changes are pushed to the state with the |
Yeah you are right. I've already changed it and squashed into one commit (quickly from another computer via HTTPS so something with my username and avatar is wrong). Could you check if it's all right now, please? |
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.
Please have a look at my comments. They are just small things, but they are important.
src/control/directive.spec.ts
Outdated
directive.ngrxUpdateOn = NGRX_UPDATE_ON_TYPE.NEVER; | ||
}); | ||
|
||
it(`should not dispatch any even if the view value changed`, done => { |
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.
The word action
is missing here, i.e. should not dispatch any action even if the view value changed
docs/user-guide/form-controls.md
Outdated
@@ -64,7 +64,7 @@ A constant `NGRX_STATUS_CLASS_NAMES` is exported to allow accessing these class | |||
|
|||
#### Choosing when to sync the view to the state | |||
|
|||
It is possible to control when view values changes are pushed to the state with the `ngrxUpdateOn` attribute. The supported values are `change` (pushed immediately when the view value changes; default) and `blur` (pushed when the form element loses focus). Note that by changing this value to something different than `change` (and thereby changing the time at which value changes are pushed to the state) you are also changing the time at which validation and other state updates that depend on the value happen. | |||
It is possible to control when view values changes are pushed to the state with the `ngrxUpdateOn` attribute. The supported values are `change` (pushed immediately when the view value changes; default), `blur` (pushed when the form element loses focus), and `never` (the value is never pushed to the state; this is an advanced feature that is useful if you want full control over when and how the state is updated but it also requires greater understanding of how ngrx-forms performs state updates). Note that by changing this value to something different than `change` (and thereby changing the time at which value changes are pushed to the state) you are also changing the time at which validation and other state updates that depend on the value happen. If you change this value to never you will need to perform all state updates yourself (e.g. setting the value, marking as dirty etc.). |
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.
In the documentation whenever I mention ngrx-forms, I make it bold. So to be consistent please change this to use **ngrx-forms**
src/control/directive.spec.ts
Outdated
describe('ngrxUpdateOn "never"', () => { | ||
beforeEach(() => { | ||
directive.ngOnInit(); | ||
directive.ngrxFormControlState = { ...INITIAL_STATE, isTouched: true, isUntouched: false }; |
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.
This is not necessary here since it leads to your additional check for the update on type not being executed. Just remove this line. The test should still work without it.
Ok it looks like I've correct all your suggestions. Please check this again and let me know. |
Sorry, for the delay. I am on vacation right now so there are bound to be some delays. However, I'll release a new version with this change right now. Thank you again for this PR. |
This PR address my proposal #118.