You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! I'm using signalStore to manage an Autocomplete custom form control component. When the user interacts with this control, there are some actions that require refocusing on its input (e.g. clicking on a selectable item from the list, clicking on an icon to clear the selected items, ...).
To keep things declarative I created a directive that focus on its consumer when a number input it has is changed, so I could just increment a counter whenever the selected items is changed, or any other possible state value changes that may require refocusing. To have more control on this counter emissions I used toObservable instead of effect. So far so good.
The problem came when I added the ControlValueAccessor implementation and realized that when the control consumer changes the control value programmatically using patchValue, setValue or whatever, then I don't want any focusing to happen. So my initial idea does not work anymore, since the state can change exactly in the same way, and I want to focus not depending on the state values, but on the action that triggered that change.
With redux we can use effects for that kind of situation, but with signalStore there's no way that I know of to 'listen' to a set of store methods which when called, trigger a side effect... So my questions:
Is there a way to do this that is integrated in signalStore? If not, what is the recommended approach?
Quite offtopic but maybe someone wants to share their knowledge: how would you implement the focus functionality in a declarative way in Angular?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi! I'm using
signalStore
to manage an Autocomplete custom form control component. When the user interacts with this control, there are some actions that require refocusing on its input (e.g. clicking on a selectable item from the list, clicking on an icon to clear the selected items, ...).To keep things declarative I created a directive that focus on its consumer when a number input it has is changed, so I could just increment a counter whenever the selected items is changed, or any other possible state value changes that may require refocusing. To have more control on this counter emissions I used
toObservable
instead ofeffect
. So far so good.The problem came when I added the
ControlValueAccessor
implementation and realized that when the control consumer changes the control value programmatically usingpatchValue
,setValue
or whatever, then I don't want any focusing to happen. So my initial idea does not work anymore, since the state can change exactly in the same way, and I want to focus not depending on the state values, but on the action that triggered that change.With redux we can use effects for that kind of situation, but with
signalStore
there's no way that I know of to 'listen' to a set of store methods which when called, trigger a side effect... So my questions:signalStore
? If not, what is the recommended approach?Beta Was this translation helpful? Give feedback.
All reactions