Grilled Cheese

ExploreLog inSign up
Terms of UsePrivacy PolicyCommunity StandardsHelpGet the app

Grilled Cheese is a product of Village Compute

Version devBuilt at: 2026-12-03 22:42:33 EST

PhotosVideosAllPeople
LatestRanked
search$.pipe(
  debounceTime(300),
  switchMap((query) =>
    this.api.search(query).pipe(
      catchError(() => EMPTY), // keeps search$ alive
    ),
  ),
);
// 1. One failing request kills the whole batch
// 2. One stream that never completes = hangs forever
forkJoin({
  user: this.api.getUser(),      // completes -> OK
  theme: this.themeStore.theme$, // BehaviorSubject -> NEVER completes!
}).subscribe(console.log);       // logs nothing, ever
zip(this.alerts$, interval(1500)).pipe(
  map(([alert]) => alert),
).subscribe((alert) => this.toast.show(alert));
// 5 errors arrive at once -> shown 1.5s apart, none dropped
items$ = this.page$.pipe(
  exhaustMap((page) => this.api.getOrders(page)),
  scan((all, next) => [...all, ...next], [] as Order[]),
);
Quiz infographic: Match three RxJS flattening operators — 1 switchMap (cancel previous, run latest), 2 exhaustMap (ignore new until current finishes), 3 concatMap (queue and run in strict order) — to three shuffled use cases: A Checkout / Pay Now button double-click, B Ordered autosave queue, C Search-as-you-type.
TypeScript code in a dark editor tab named feed.ts. A Feed component lists posts with @for, each with a Like button that calls likes$.next({ id: post.id, liked: !post.liked }). likes$ is a Subject. In the constructor, likes$ is piped through groupBy((like) => like.id), then mergeMap((post$) => post$.pipe(switchMap((like) => this.api.setLiked(like)))), all three lines highlighted, under the comment "liking post 2 no longer cancels the request for post 1". It ends with takeUntilDestroyed() and subscribe().
Infographic titled "Where did all my RxJS operators go?" with the line "In Angular 22, most of them became signals." Five RxJS operators, each with an arrow down to the Angular signal API that replaced it: BehaviorSubject to signal(), combineLatest to computed(), debounceTime to debounced(), switchMap to httpResource(), and subscribe to effect(). Below, a timeline labeled "Still RxJS" with exhaustMap, concatMap, retry and webSocket.
Angular code in export.ts. A component with selector 'app-export' and the template: <button (click)="start$.next()">Export report</button>, then @let job = exportJob(); @if (job?.status === 'running') shows <progress [value]="job.progress" max="100">, @else if (job?.status === 'done') shows <a [href]="job.fileUrl">Download report</a>. In class Export: private readonly http = inject(HttpClient); readonly start$ = new Subject<void>(); readonly exportJob = toSignal(this.start$.pipe(switchMap(() => this.http.post<{ id: string }>('/api/exports', {})), switchMap(({ id }) => timer(0, 2000).pipe(switchMap(() => this.http.get<ExportJob>(`/api/exports/${id}`)), takeWhile((job) => job.status === 'running', true))))). The takeWhile line is highlighted.
Angular code in app.ts. const ACTIVE_EVENTS = ['click', 'scroll', 'keydown', 'mousemove']. A component with selector 'app-root' and the template: @if (isInactive()) { <p class="notice">You have been inactive for a while 👀</p> }. In class App: readonly isInactive = toSignal(merge(...ACTIVE_EVENTS.map((event) => fromEvent(document, event))).pipe(startWith(null), switchMap(() => timer(10_000).pipe(map(() => true), startWith(false)))), { initialValue: false }). The merge line and the switchMap line are highlighted.
Angular code in report.service.ts. An @Injectable({ providedIn: 'root' }) class ReportService with private readonly http = inject(HttpClient). Its getReport() method returns this.http.get<Report>('/api/report').pipe(retry({ ... })). The retry config (highlighted) has count: 3, with the comment "give up after 3 retries", and delay: (error: HttpErrorResponse, attempt) => { ... }. Inside, with the comment "a 404 won't fix itself, fail right away": if (error.status < 500) { return throwError(() => error); }. Then return timer(2 ** attempt * 1000), with the comment "wait 2s, 4s, 8s" (highlighted).
TypeScript code in audit-map.ts, a custom RxJS operator built from throttle and concatMap; the throttle line is highlighted:

import { concatMap, defer, finalize, from, Subject, throttle } from 'rxjs';
import type { ObservableInput, OperatorFunction } from 'rxjs';

export function auditMap<T, R>(
  project: (value: T) => ObservableInput<R>,
): OperatorFunction<T, R> {
  return (source) =>
    defer(() => {
      const done = new Subject<void>();

      return source.pipe(
        // first value goes through, then only the latest until `done`
        throttle(() => done, { leading: true, trailing: true }),
        concatMap((value) =>
          from(project(value)).pipe(finalize(() => done.next())),
        ),
      );
    });
}