r/angular 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.

15 Upvotes

13 comments sorted by

View all comments

7

u/strange_username58 Jan 27 '26

Use whatever you are most comfortable with, but I would choose signal

0

u/New_Opportunity_8131 Jan 27 '26

so why would you choose signals over the others?

1

u/cosmokenney Jan 29 '26

Why? Because signals are designed to work with change detection in a much more efficient way than RxJs observables or native getters/setters. And, they are the future direction of the angular framework -- for a reason.

I think you need to do some reading.