From 721ee7df5ce488d6ed0ada2a38f8ad3166a84060 Mon Sep 17 00:00:00 2001 From: sli <61759464+LeonidSimakov@users.noreply.github.com> Date: Sun, 8 Dec 2024 21:43:52 +0300 Subject: [PATCH] fix(kit): fix parallel lazy loading tree nodes The node loading engine should not cancel the previous request, because these requests are for different nodes. If switchMap cancels a request, then the loading for the cancelled node is always running. https://t.me/taiga_ui/7924/25725 --- projects/kit/components/tree/misc/tree.service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/kit/components/tree/misc/tree.service.ts b/projects/kit/components/tree/misc/tree.service.ts index 213ea2e10041..d0192a419778 100644 --- a/projects/kit/components/tree/misc/tree.service.ts +++ b/projects/kit/components/tree/misc/tree.service.ts @@ -1,5 +1,5 @@ import {inject, Injectable} from '@angular/core'; -import {map, startWith, Subject, switchMap, tap} from 'rxjs'; +import {map, mergeMap, startWith, Subject, tap} from 'rxjs'; import type {TuiTreeLoader} from './tree.interfaces'; import {TUI_TREE_LOADER, TUI_TREE_LOADING, TUI_TREE_START} from './tree.tokens'; @@ -13,7 +13,7 @@ export class TuiTreeService { private readonly load$ = new Subject(); public readonly data$ = this.load$.pipe( - switchMap((item) => + mergeMap((item) => this.loader.loadChildren(item).pipe( tap((children) => this.map.set(item, children)), map((children) =>