Skip to content

Commit c45528f

Browse files
authored
Merge pull request #128 from cloudnc/fix/deprecate-on-form-update-hook
fix: deprecate `OnFormUpdate` hook
2 parents 6880f18 + aa3c9a7 commit c45528f

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ export class CrewMemberComponent extends NgxSubFormComponent<CrewMember> {
538538

539539
**Hooks**
540540

541-
- `onFormUpdate`: Allows you to react whenever the form is being modified. Instead of subscribing to `this.formGroup.valueChanges` or `this.formControls.someProp.valueChanges` you will not have to deal with anything asynchronous nor have to worry about subscriptions and memory leaks. Just implement the method `onFormUpdate(formUpdate: FormUpdate<FormInterface>): void` and if you need to know which property changed do a check like the following: `if (formUpdate.yourProperty) {}`. Be aware that this method will be called only when there are either local changes to the form or changes coming from subforms. If the parent `setValue` or `patchValue` this method won't be triggered
541+
- `onFormUpdate` [**_deprecated_**]: Allows you to react whenever the form is being modified. Instead of subscribing to `this.formGroup.valueChanges` or `this.formControls.someProp.valueChanges` you will not have to deal with anything asynchronous nor have to worry about subscriptions and memory leaks. Just implement the method `onFormUpdate(formUpdate: FormUpdate<FormInterface>): void` and if you need to know which property changed do a check like the following: `if (formUpdate.yourProperty) {}`. Be aware that this method will be called only when there are either local changes to the form or changes coming from subforms. If the parent `setValue` or `patchValue` this method won't be triggered
542542
- `getFormGroupControlOptions`: Allows you to define control options for construction of the internal FormGroup. Use this to define form-level validators
543543
- `createFormArrayControl`: Allows you to create the `FormControl` of a given property of your form (to define validators for example). When you want to use this hook, implement the following interface `NgxFormWithArrayControls`
544544
- `handleEmissionRate`: Allows you to define a custom emission rate (top level or any sub level)

projects/ngx-sub-form/src/lib/ngx-sub-form.types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import { FormControl, FormGroup, ValidationErrors } from '@angular/forms';
22
import { Observable } from 'rxjs';
33
import { ArrayPropertyKey, ArrayPropertyValue, Controls, FormUpdate } from './ngx-sub-form-utils';
44

5+
// @deprecated
56
export interface OnFormUpdate<FormInterface> {
7+
// @deprecated
68
onFormUpdate?: (formUpdate: FormUpdate<FormInterface>) => void;
79
}
810

0 commit comments

Comments
 (0)