RxJS Fundamentals
Observables, observers, subscriptions, subjects, operators basics, cold vs hot observables, unsubscribe strategies
1What is an Observable in RxJS?
What is an Observable in RxJS?
Answer
An Observable is a lazy collection of multiple values over time. It represents a data stream that can emit zero, one, or multiple values synchronously or asynchronously. Unlike Promises which emit a single value, Observables can emit multiple values and support cancellation via unsubscribe.
2What is the main difference between an Observable and a Promise?
What is the main difference between an Observable and a Promise?
Answer
Observables can emit multiple values over time and are cancellable with unsubscribe, while Promises emit a single value (resolve or reject) and cannot be cancelled once started. Additionally, Observables are lazy (execute only on subscription) while Promises are eager (execute immediately).
3How to create a simple Observable that emits values 1, 2, 3?
How to create a simple Observable that emits values 1, 2, 3?
Answer
The of() method from RxJS creates an Observable that emits the provided values as arguments synchronously, then completes. It's the simplest creation operator for known values. Alternatives: from() to convert an array/iterable, or new Observable() for full control over the emission flow.
What happens if you don't unsubscribe from an Observable?
What is a Subject in RxJS?
+19 interview questions
Other Angular interview topics
TypeScript Basics
TypeScript Advanced
Angular Fundamentals
Components & Lifecycle
Services & Dependency Injection
Angular Modules Organization
Angular CLI
Directives & Pipes
Routing & Navigation
Reactive Forms
Template-driven Forms
RxJS Operators
HttpClient & API Calls
Basic State Management
Change Detection
Angular Signals
Standalone Components
Angular Unit Testing
End-to-End Testing
Build & Optimization
NgRx Fundamentals
NgRx Advanced
Angular Architecture
Performance Optimization
Security & Best Practices
Advanced RxJS Patterns
Angular Universal & SSR
Angular Micro-frontends
Master Angular for your next interview
Access all questions, flashcards, technical tests, code review exercises and interview simulators.
Start for free