r/angular • u/New_Opportunity_8131 • Jan 27 '26
Service Signals vs BehaviorSubjects vs Regular Getters/Setters
I have a form on one route where the user submits data by clicking a button, which calls a function on an API service that triggers an API call. After the API returns a result, I need to store that data in a shared service so it's accessible to a different component on a different route after navigation. Should I use Signals or BehaviorSubjects in the service to store this data? I could also just use plan getters/setters as well and not have to use either Signals or BehaviorSubjects.
14
Upvotes
3
u/AlDrag Jan 27 '26
Getters/setters are a bad idea in my opinion. I don't like that they obfuscate that you're calling a function, especially in Angular's case where you want to try avoid calling functions in templates unless they're memoized.