blog/angular-signals-push-pull #14
Replies: 1 comment 3 replies
-
Hi Tomas! Congratulations for your article. It's incredibly detailed. However, I still have a question about what would be the best approach for the following scenario. I have a global service that internally uses a private signal to store the content of one or more dynamic menus updated asynchronously during the resolve function configured in a Route. This service must be consumed in the template of each component (all onPush) to display the corresponding menu reactively. Currently, I only expose a getter in the service that reads the current value of the signal, preventing a component from being able to write directly to the signal and also to be accessed as a readonly property sintax. The question is: In this case, does the component template that reads the property (getter) still act as a ReactiveNode, or only when I read the signal value directly in the template? My tests suggest that this approach works even without interacting with the component, but I'm not sure if it's just the change detection mechanism itself acting up without me noticing. Additionally, I would like to know if it is a good practice (I don't think so) to expose a WritableSignal from a service, and what would be the ideal approach for this scenario. Create a computed() only for this readonly pourpose? Thanks! |
Beta Was this translation helpful? Give feedback.
-
blog/angular-signals-push-pull
Let's take a deep dive into Angular signals and how they can be understood using the primitive push & pull concepts to make sense of all their behaviors from setting a value all the way to effects and laziness!
https://angularexperts.io/blog/angular-signals-push-pull
Beta Was this translation helpful? Give feedback.
All reactions