Вキ
Size: a a a
Вキ
AT
const newArray = [];
for (const item of array) {
newArray.push(item);
if (item.catId === 1) {
break;
}
}
AT
Вキ
S
export function setIsLoading<T>(callback: (isLoading: boolean) => void): MonoTypeOperatorFunction<T> {Пример с локальным стейтом:
return source =>
defer(() => {
callback(true);
return source.pipe(finalize(() => callback(false)));
});
}
class MyComponent<T> {
readonly isDataLoading$ = new ReplaySubject<boolean>(1);
readonly data$ = new BehaviourSubject<T | null>(null);
loadData(): void {
this.service.getData().pipe(
setIsLoading(isLoading => this.isDataLoading$.next(isLoading)),
takeUntilDestroyed(this),
).subscribe(this.data$);
}
}
Вキ
export function setIsLoading<T>(callback: (isLoading: boolean) => void): MonoTypeOperatorFunction<T> {Пример с локальным стейтом:
return source =>
defer(() => {
callback(true);
return source.pipe(finalize(() => callback(false)));
});
}
class MyComponent<T> {
readonly isDataLoading$ = new ReplaySubject<boolean>(1);
readonly data$ = new BehaviourSubject<T | null>(null);
loadData(): void {
this.service.getData().pipe(
setIsLoading(isLoading => this.isDataLoading$.next(isLoading)),
takeUntilDestroyed(this),
).subscribe(this.data$);
}
}
DT
DT
DT
arr.slice(0, arr.findIndex(el => el.catId === 1) - 1)
Вキ
arr.slice(0, arr.findIndex(el => el.catId === 1) - 1)
SS
AT
AT
Вキ
DT
DT
Вキ
DT
AS
DT