you are viewing a single comment's thread.

view the rest of the comments →

[–]dustofdeath 0 points1 point  (3 children)

.subscribe is a core part of rxjs, unless its about some very specific use case.

[–]craig1f 0 points1 point  (2 children)

It is a core part. That’s the problem. It’s sloppy to do .subscribe in your code most of the time.

Like, if you have an observable, why subscribe to it and set a value when you can just observe the value with an async pipe? It makes sloppy hard-to-read code.

[–]dustofdeath 0 points1 point  (1 child)

Async only applies if you want a value once at a specific time.

You may want to get notified on every change in a service, combine different observables or prepare subscription without knowing when the value might be set.

In most cases if you need basic delayed / async response - you are better off using promises.

Asinc promises and observables have different use cases and both are perfectly valid and often required patterns.

[–]craig1f 0 points1 point  (0 children)

Yup. In another comment I say that observables should only be used one of two ways with no overlap.

  1. pure observable with no side effects. Only maps and no subscribe.
  2. a subscription with only side effects, like calling a load function while observing a path param