interview community logo

0
0
What is the difference between stateful and stateless service?
1 answer

Angular Robert Isaac asked 1 year ago


0

Stateless service is a service that always do the same action with no side affects no matter how many times you call it, for example to make http call and return the result

Stateful service is a service that does something different depending on how many times you call it, for example if you cache the response in a service so first time you call the method it will make http, but second time it will not make any http call and will return the response from the cashe Another example is login, after login you are saving the returned token in local storage, so it's stateful because it has side affects

Robert Isaac answered 1 year ago loading comments...