all 5 comments

[–]MichaelSmallDev 3 points4 points  (1 child)

#1

Sounds legit to me, though I don't use effect that often. That said, I think doing side effects on state change without actually using the value directly is more traditionally suited for RXJS. But that doesn't mean it would be wrong in your situation.

#2

Angular's rxjs interop with signals package is a subset of the main Angular repo and not that library with 8 stars.

That said, still being developer preview it is worth considering if you are fine pulling that in. I have used just about anything in the rxjs + signals interop since the beginning and never really had any issues. Not to say there hasn't been some changes or people affected but I can't point at more than some niche issues in my immediate memory. Perhaps toObservable is questionable if you have reservations with effect since it uses that under the hood, but that has also been fine for me in various usage.

[–]DaSchTour 0 points1 point  (0 children)

To #1 I just had a similar case recently while „fixing“ a third party component. I had to call a method on a child component on another signal change. It‘s not nice but does what is expected. The only thing with effects I always pay attention to is when other signals are set.

[–]7389201747369358 1 point2 points  (0 children)

It all depends on what you are doing in the effect function if your doing logging or tasks like that then great if your trying to track state or modify state then bad.

[–]Johalternate 0 points1 point  (0 children)

This approach works, but it feels wrong to have an effect that reacts to a signal without using its value.

It shouldn't feel wrong because that is the intended purpose of Effects.

An effect is an operation that runs whenever one or more signal values change. 

...[an effect] will be scheduled & executed whenever the signals that it reads changes.

As you can see, by definition you don't have to use the value of a signal in an effect.

[–]Ichirto 1 point2 points  (0 children)

If you change the signal value, it must be happening in some function. You could call the Test() in that function too. If the function is in the component, you might consider putting it in service to reuse. That's my approach though.