Answer the question
In order to leave comments, you need to log in
Why do many people use angular observables in services?
I create a variable and functions in the service and manipulate the variables there.
I looked at the code of other programmers - they all have implemented observables, subject and changing not just a variable, but .next (value).
As I understand it, this is the correct approach. Only I didn’t understand the difference, because everything works for me through variables.
What are the pitfalls of this approach?
Thanks
Answer the question
In order to leave comments, you need to log in
Observable - observable object. observable .
Its consumer can always know when changes have occurred, run a view update, plus build their own flow chains from operators.
And if you just changed something in the service there, Angular will most likely not know about it. The fact that it works for you means that somewhere at that time the change check worked (most likely global), i.e. it was just luck.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question