И
switchMap(() => this.apiService.call())
skipWhile(res => !res.status),
take(1),
).subscribe(res=> console.log(res));
Size: a a a
И
И
LT
LT
RC
И
И
И
LT
S
function retryUntil<T>(source: () => Observable<T>, condition: (value: T) => boolean): Observable<T> {
return source().pipe(
switchMap(value => condition(value)
? of(value)
: concat(of(value), retryUntil(source, condition))
),
);
}Вキ
function retryUntil<T, O>(
project: (index: number) => Observable<O>,
condition: (data: O, index: number) => boolean
): Observable<O> {
return of(undefined).pipe(
expand((data: O, i: number): Observable<O> =>
i > 0 && condition(data, i)
? EMPTY
: project(i)),
filter(condition)
);
}
// пример
const retryLoadUntil = params =>
retryUntil(() => load(params), notNull);
source.pipe(switchMap(retryLoadUntil))
LT
function retryUntil<T, O>(
project: (index: number) => Observable<O>,
condition: (data: O, index: number) => boolean
): Observable<O> {
return of(undefined).pipe(
expand((data: O, i: number): Observable<O> =>
i > 0 && condition(data, i)
? EMPTY
: project(i)),
filter(condition)
);
}
// пример
const retryLoadUntil = params =>
retryUntil(() => load(params), notNull);
source.pipe(switchMap(retryLoadUntil))
Вキ
S
LT
LT
LT
LT
AS
function retryUntil<T, O>(
project: (index: number) => Observable<O>,
condition: (data: O, index: number) => boolean
): Observable<O> {
return of(undefined).pipe(
expand((data: O, i: number): Observable<O> =>
i > 0 && condition(data, i)
? EMPTY
: project(i)),
filter(condition)
);
}
// пример
const retryLoadUntil = params =>
retryUntil(() => load(params), notNull);
source.pipe(switchMap(retryLoadUntil))