RxJS in Angular: Reactive Extensions for JavaScript

🚀 **Day 1 – #RxJS Journey** **Part 1: What is RxJS & Why in Angular?** #RxJS = **Reactive Extensions for #JavaScript** Starting the journey with one of the most powerful concepts in Angular — **#RxJS** 👉 In simple terms: RxJS helps you handle **asynchronous data, events, and streams** in a clean and scalable way. --- ### Why RxJS in Angular? ✔️ HTTP Calls → `HttpClient` returns Observables ✔️ Forms → `valueChanges` is an Observable ✔️ Routing → `ActivatedRoute.paramMap` is an Observable ✔️ State Management → NgRx is built on RxJS ✔️ Real-time UI → React instantly to user actions and data changes --- ### What is an Observable? Think of it like a Netflix subscription 📺 👉 Subscribe once → keep receiving data over time ✔️ Can emit multiple values ✔️ Can complete, error out, or keep streaming ✔️ Nothing happens until you subscribe --- ### Basic RxJS in Angular ```ts cityList: string[] = ["Pune", "Mumbai", "Nagpur"]; cittList$ = of(["Pune", "Mumbai", "Nagpur"]); cityList2$ = from(["Pune", "Mumbai", "Nagpur"]) constructor() {  this.cittList$.subscribe((cityData: string[])=>{   console.log(cityData)  })  this.cityList2$.subscribe((res: string)=>{   console.log(res)  })  const myObs$ = new Observable(value=>{   value.next("This is Demo Text")  }) } ``` --- ### Key Learnings ✔️ `of()` → emits the entire array at once ✔️ `from()` → emits one value at a time ✔️ `Observable` → create your own data stream --- **Mindset:** Consistency > Perfection Next up: RxJS Operators #RxJS #Angular #WebDevelopment #Frontend #LearnInPublic #SatendraCoder

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories