Thuta Learning
ရှာဖွေရန်
AdvancedWeb Developmentintermediate

RxJS Operators

စိတ်လျှော့ပါ။ ဒီခန်းကို စာအုပ်လိုမဟုတ်ဘဲ စကားပြောသလိုပဲ၊ နားလည်လွယ်အောင် ရှင်းပါမယ်။

RxJS Operators များသည် Observable streams များကို transform, filter, နှင့် combine လုပ်ရန် အသုံးပြုသည်။

typescript
import { map, filter, debounceTime, switchMap } from 'rxjs/operators';
import { fromEvent } from 'rxjs';

// map - transform each value
this.http.get<User[]>('/api/users').pipe(
  map(users => users.map(u => u.name))
).subscribe(names => console.log(names));

// filter - only emit values that pass condition
this.numbers$.pipe(
  filter(num => num % 2 === 0)  // only even numbers
).subscribe(even => console.log(even));

// debounceTime - wait before emitting (good for search)
const searchBox = document.getElementById('search');
fromEvent(searchBox, 'input').pipe(
  debounceTime(300),  // wait 300ms after typing stops
  map((event: any) => event.target.value)
).subscribe(searchTerm => this.search(searchTerm));

// switchMap - switch to new observable, cancel previous
this.searchControl.valueChanges.pipe(
  debounceTime(300),
  switchMap(term => this.searchService.search(term))
).subscribe(results => this.results = results);
You should see
(Operators များသည် Observable streams များကို powerful ways များဖြင့် manipulate လုပ်နိုင်သည်)
RxJS Operators | Thuta Learning