Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private updateStore(formName: keyof FormsState, form: AbstractControl, initial = false) {
const value = this.buildFormStoreState(formName, form);
const capitalized = formName[0].toUpperCase() + (formName as any).slice(1);
const action = `${initial ? 'Create' : 'Update'} ${capitalized} Form`;
logAction(action);
this.store.update({
[formName]: value
} as any);
}
private removeFromStore(formName: keyof FormsState) {
const snapshot = this.query.getValue();
const newState: Partial = Object.keys(snapshot).reduce((acc, currentFormName) => {
if (formName !== currentFormName) {
acc[currentFormName] = snapshot[currentFormName];
}
return acc;
}, {});
logAction(`Remove ${formName}`);
this.store._setState(() => newState as any);
}