Suggest an editImprove this articleRefine the answer for “What does takeUntil() do?”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)`takeUntil()` is an RxJS operator that **automatically completes a subscription** when another stream fires. **Key point:** the subscription stays alive until a stop signal arrives - no leaks.Shown above the full answer for quick recall.Answer (EN)Image`takeUntil()` is an RxJS operator that **automatically completes a subscription** when another stream fires. --- ### In simple terms: You're saying: **"Listen to this stream until this other event happens."** --- ### Example: ```ts private destroy$ = new Subject<void>(); this.myStream$ .pipe(takeUntil(this.destroy$)) .subscribe(value => { console.log(value); }); // When the component is destroyed: this.destroy$.next(); // stops the subscription this.destroy$.complete(); ``` This is handy in Angular for unsubscribing automatically in `ngOnDestroy()`. --- ### Without `takeUntil()`: You'd have to store the subscription and manually call `unsubscribe()`. With `takeUntil()`, everything happens through the stream: **reactive and safe.** --- ### Where it's used: - In Angular components - When working with `interval()`, `valueChanges`, `router.events`, and other infinite streams --- ### Conclusion: `takeUntil()` = a way of saying: **"The subscription should stay alive until a stop signal arrives."** No leaks, everything under control.For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.