takeWhile can leak subscriptions for the same reasons as
takeUntil. However, the placement of a
takeWhile will affect how it behaves, as it calls the specified callback only when a value is received. So there’s no general rule for where a
takeWhile should be placed.
Also, as Stas Rivkin pointed out in his response,
takeWhile is less suitable as an indirect unsubscription mechanism. It depends on a value being emitted for the
this.isAlive flag to be checked, which means the any unsubscription will occur later than the component’s destruction — if at all.
In you code, you don’t have a subscription to another observable to leak — you’re just mapping the value — but you do have the problem that Stas highlighted.