Skip to content

Commit 50d4428

Browse files
committed
Refactor to subscribe to dataChanges only once.
1 parent 5402578 commit 50d4428

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/lib/src/json-schema-form.component.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -690,16 +690,12 @@ export class JsonSchemaFormComponent implements ControlValueAccessor, OnChanges,
690690
// }
691691

692692
// Subscribe to form changes to output live data, validation, and errors
693-
this.jsf.dataChanges.subscribe(data =>
694-
this.onChanges.emit(this.objectWrap ? data['1'] : data)
695-
);
696-
if (this.formValuesInput && this.formValuesInput.indexOf('.') === -1) {
697-
this.jsf.dataChanges.subscribe(data => {
698-
if (this.formValuesInput) {
699-
this[`${this.formValuesInput}Change`].emit(this.objectWrap ? data['1'] : data)
700-
}
701-
});
702-
}
693+
this.jsf.dataChanges.subscribe(data => {
694+
this.onChanges.emit(this.objectWrap ? data['1'] : data);
695+
if (this.formValuesInput && this.formValuesInput.indexOf('.') === -1) {
696+
this[`${this.formValuesInput}Change`].emit(this.objectWrap ? data['1'] : data);
697+
}
698+
});
703699

704700
// Trigger change detection on statusChanges to show updated errors
705701
this.jsf.formGroup.statusChanges.subscribe(() => this.changeDetector.markForCheck());

0 commit comments

Comments
 (0)