R
R
Roman Rakzin2020-06-16 19:35:53
Angular
Roman Rakzin, 2020-06-16 19:35:53

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

1 answer(s)
A
Anton Shvets, 2020-06-16
@Xuxicheta

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 question

Ask a Question

731 491 924 answers to any question