Angular - RxJS and Observables FundamentalsWhich Angular lifecycle hook is best suited to perform unsubscription from Observables?AngAfterViewInitBngOnInitCngOnDestroyDngDoCheckCheck Answer
Step-by-Step SolutionSolution:Step 1: Identify lifecycle hooks purposengOnDestroy is called just before the component is removed from the DOM.Step 2: Match unsubscription timingUnsubscribing should happen when component is about to be destroyed to free resources.Final Answer:ngOnDestroy -> Option CQuick Check:Unsubscribe in ngOnDestroy = C [OK]Quick Trick: Use ngOnDestroy to clean up subscriptions [OK]Common Mistakes:MISTAKESTrying to unsubscribe in ngOnInitUsing ngAfterViewInit for unsubscriptionConfusing ngDoCheck with cleanup hook
Master "RxJS and Observables Fundamentals" in Angular9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallPerf
More Angular Quizzes Angular Change Detection - Default change detection strategy - Quiz 11easy Angular Change Detection - Zone.js and automatic detection - Quiz 8hard Angular Change Detection - When to use OnPush - Quiz 10hard Angular Change Detection - Zone.js and automatic detection - Quiz 13medium HTTP Client - Handling HTTP errors - Quiz 8hard Reactive Forms - Validators (required, minLength, pattern) - Quiz 9hard Reactive Forms - Form state tracking (dirty, touched, valid) - Quiz 6medium Routing - RouterModule configuration - Quiz 1easy RxJS Operators - combineLatest and forkJoin for combining - Quiz 12easy Services and Dependency Injection - Why services are needed - Quiz 7medium