Skip to main content
100%

RxJS Switch Map

✓ Published0🌍 Public
RRestuta
Last edited Jun 28, 2017
Created on Jun 28, 2017

This example demonstrates the behavior of RxJS’s `switchMap` operator when combined with a custom sorter function that merges values from two observable streams. The code creates two observables emitting numbers (1,2,3 and 40,50,60) and passes them through `switchMap` with a `createSorter` callback that accumulates, sorts, and pops values from an internal list. Each emitted value is logged to the console, showing how `switchMap` switches between the source observables while the sorter maintains state across emissions. The gist uses RxJS’s `Observable.of` and `subscribe` methods.

AI-generated description

Similar vizzes