Move important side effects from do() to subscribe()

André Staltz
InstructorAndré Staltz

Share this video with your friends

Send Tweet

The do() operator allows us to perform side effects in the chain of operators. However, there are limited use cases for do(). We will learn what those use cases are and how to use subscribe() most of the times.

Adam
Adam
~ 4 years ago

Also, I have had the case where I wanted a required side effect to occur but only when there was a subscriber for the "main" observable. I suppose the "correct" way to enforce that would be to expose an observable that is the result of merge ?

Viktor Soroka
Viktor Soroka
~ 3 years ago

Julia, I do think you are right about triggering twice regarding click observable. It would be one hit as click is hot observable.

ganqqwerty
ganqqwerty
~ a year ago

what about the situations when we use the async pipe in Angular? the subscription and unsubscription happens automatically in the template, so we can't have subscribe