constructor() {
const ngFormStateManager = this.actions.store.form
.bind(this.form, { emitEvent: true, onChangePairwise: true })
.onPropertyChange<MyState>(
'quarterIncome',
this.recalculateMonthlyIncome,
)
.onPropertyChange<MyState>(
'monthlyIncome',
this.recalculateQuarterIncome,
);
this.destroyRef.onDestroy(() => {
this.actions.store.reset();
ngFormStateManager.destroy();
});
}
private recalculateMonthlyIncome = (quarterIncome: number): void => {
const monthlyIncome = quarterIncome ? parseFloat((quarterIncome / 3).toFixed(4)) : 0;
this.actions.updateMonthIncome(monthlyIncome);
};