ngxs / store

πŸš€ NGXS - State Management for Angular

Home Page:http://ngxs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

πŸš€[FEATURE]: for @ngxs/form-plugin : Add information on which control was updated

matndev opened this issue Β· comments

Relevant Package

The package is @ngxs/form-plugin

Description

At the moment, there is no information about which control of the form was updated in the state when the user fill a new value.

Describe the problem you are trying to solve

If some fields are dependents I need to know which one was updated to perform a specific action.
Here is a usecase :

Input : Amount 1
Input : Amount 2
Input : Sum

If I change amount 1, sum needs to be updated.
If I change sum, amount 1 and amount 2 need to be recalculated to be equals to the sum.

To do that knowing the updated field is required.

Describe the solution you'd like

If possible expose a selector we can subscribe to in order to perform an action after the specific field was updated.

// Add subject.next() in error() and subscribe()
    this._store.dispatch(actions).subscribe({
      error: () => (this._updating = false),
      complete: () => (this._updating = false)
    });

https://github.com/ngxs/store/blob/fc39b5671ffcf0e27c73f5569e6048b583e63f6a/packages/form-plugin/src/directive.ts

Describe alternatives you've considered

No workarounds founds at the moment.