One reason I can think of: Signals are reactive; variables are not. If you have a signal that changes, all dependent signals will update accordingly. If you have a variable that changes, the required changes need to be signaled via an observable. RxJS subjects are most commonly used for this purpose. That way you can send data from one component and receive data in another component by subscribing to the observable variable. The important difference is the ability to listen for changes. Variables can't do that, unless they are observables. Signals on the other hand, do exactly that.
stackblitz.com/edit/stackblitz-starters-ug8svk
nice video 👌
But sharing this counter between conponent can be done without using service?
these are two independent components and data transfer is done through a service. counter is just an example of data.
@@zorefcode How to make components Change Detection strategy On.Push, and then receive the Signal from service.
How to implement Change detection On.Push strategy, in this ?
This is doable using regular variables in the service component. Why do we need to use signals pls explain thank you
Because using default variable in service will force you to listening this value
One reason I can think of:
Signals are reactive; variables are not.
If you have a signal that changes, all dependent signals will update accordingly. If you have a variable that changes, the required changes need to be signaled via an observable. RxJS subjects are most commonly used for this purpose. That way you can send data from one component and receive data in another component by subscribing to the observable variable.
The important difference is the ability to listen for changes. Variables can't do that, unless they are observables. Signals on the other hand, do exactly that.