Replies: 1 comment
-
We need the same feature (listening when a method is called, not when a state is changed) for a different reason: we'd like to automatically register an "analytics event" when store methods are called. In other words, I'd like to automatically decorate all methods in the signal store with
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
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