For me,signal just looks like useState and useEffect in React,with more functionalities like mutable and compute.But,in my opinion change detection will easier and quicker by signals.
Signals are not just easier to grasp, than RXJS, but they are also closer to what's actually happening under the hood. - the fact alone, that your effect methods now can run sync instead of async, without frankensteining your ngOnChange method, is a feature in itself
At the moment I just don't really like the idea of making async things sync just by using toSignal with an arbitrary initial value. Sometimes, effects don't work as desired/expected when this arbitrary value comes in as the first value before the database value. For example, my effect needed to calculate a default value for a form field when it was null, so I did it in an effect, but the problem was this arbitrary value came in before the db value and so the wrong value was assigned to the form field. In my opinion, it is better to just wait for the database value, which means using rxjs instead of a signal. In my opinion it is better to use rxjs for async stuff, and use signals for sync stuff if you want, but for me I find it simpler to just use rxjs for everything.
Thank you very much for your valuable content , but i need to ask a question regarding the computed and specially for the example you used what the different between calling usersTotal() in the html template and calling users().length directly ? is there any advantage of using computed in this case ? and thanks again
In this case not really. computed is some logic that you want to compute. Reading length has no logic so you don't need computed. It is also a good place for logic which you don't want to write in html.
I really don't like the esthetics of signals. Code separation which ngrx offers make code base really clean. I hope angular team comes up with something which makes code looks cleaner.
Thank you! Amazing video! What is the difference between update() and mutate()? Does update() trigger change detection in the current component while mutate() does not?
The video was very clear! I just didn't understand how effect works: how does it know to trigger when title is changed and not when users does? Does it trigger every time any signal change?
As for now effect is called if any signal changes. I would like to see some api to trigger it only for specific signal similar to dependencies of useEffect in react
Effects will only run if any of their dependencies change, from the docs: Effects always run at least once. When an effect runs, it tracks any signal value reads. Whenever any of these signal values change, the effect runs again. Similar to computed signals, effects keep track of their dependencies dynamically, and only track signals which were read in the most recent execution.
@@MonsterlessonsAcademy we have in rxjs multicast operators (BehaviorSubject - ReplySubject - AsyncSubject, EventEmitter) son we can achieve exactly the saqme as Signals
Sorry for out of context question, in ngrx can and should i update state from the backend service without any actions dispatched from from user (commercial platform) Thanks in advance
Hi, exists something like a benchmark? I learned that we should not call functions in Angular because it will make the app significantly slower. But with the signal you added a function to the view. How fast is it compared to older approaches?
Calling signals is not like calling a function, it's perfectly safe to do. Calling a function is discouraged due to Angular's change detection mechanism, but signals won't trigger change detection like functions would in the template.
@@MonsterlessonsAcademy I disagree - they both do state management, they both can interconnect components, and they both stream data the same way. In fact they are really no different than a behavior subject.