← All Angular Web Framework Flashcard Decks

RxJS & Observables Flashcards

6 cards from real Angular Web Framework practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.

Read the first 6 RxJS & Observables flashcards as text
  1. What is an Observable in Angular/RxJS?

    Answer: A lazy collection of values that can emit multiple items over time and be subscribed to

    An Observable represents a stream of values over time, producing data only when subscribed to (lazy evaluation), and can emit zero or more values before completing or erroring.

  2. What is the difference between a Subject and an Observable?

    Answer: A Subject is both an Observable and an Observer — it can emit values and be subscribed to

    A Subject is multicast (multiple subscribers), can manually emit values using next(), and acts as both an Observable (can be subscribed to) and an Observer (can receive values).

  3. What does the pipe() method do in RxJS?

    Answer: Chains multiple operators together to transform, filter, or combine Observable streams

    The pipe() method allows composing multiple RxJS operators (map, filter, switchMap, etc.) into a processing pipeline that transforms the Observable stream.

  4. What is the switchMap operator used for?

    Answer: To cancel the previous inner Observable and subscribe to a new one when the source emits

    switchMap maps each source value to an inner Observable, automatically unsubscribing from the previous inner Observable when a new source value arrives, preventing stale requests.

  5. Why is it important to unsubscribe from Observables?

    Answer: To prevent memory leaks by cleaning up subscriptions that are no longer needed

    Failing to unsubscribe from Observables (especially those that don't complete naturally) creates memory leaks, as the subscription continues holding references and processing emissions.

  6. What is the async pipe in Angular templates?

    Answer: A pipe that automatically subscribes to an Observable, displays the latest value, and unsubscribes on destroy

    The async pipe subscribes to an Observable or Promise in the template, renders the latest emitted value, and automatically unsubscribes when the component is destroyed, preventing memory leaks.