BACK
ПрактикаInterview: mergeMap() concurrency argument
ПРАКТИКА · 70 · 練

Interview: mergeMap() concurrency argument

Используйте mergeMap с concurrency 2 для загрузки ids.

  1. Решите задачу в редакторе без длинной теории.
  2. Запустите проверку и сравните вывод с ожидаемым.
  3. Если застряли, откройте решение и перенесите подход в свой код.
Решение spoiler · click to reveal
const { from, of, mergeMap } = Rx;

const load = id => of('item-' + id);

const result$ = from([1, 2, 3]).pipe(
  mergeMap(id => load(id), 2)
);

result$.subscribe(value => console.log(value));
script.ts // TypeScript
CONSOLE · Console Output
Нажмите на запуск, чтобы увидеть результат...