[cli-dev-mode] get values from completed state subjects (#107428)
Co-authored-by: spalger <spalger@users.noreply.github.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
48a97f6d18
commit
3d8a2cfcf1
1 changed files with 23 additions and 7 deletions
|
@ -77,8 +77,11 @@ export interface CliDevModeOptions {
|
||||||
cache: boolean;
|
cache: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const firstAllTrue = (...sources: Array<Rx.Observable<boolean>>) =>
|
const getValue$ = <T>(source: Rx.BehaviorSubject<T>): Rx.Observable<T> =>
|
||||||
Rx.combineLatest(sources).pipe(
|
source.isStopped ? Rx.of(source.getValue()) : source;
|
||||||
|
|
||||||
|
const firstAllTrue = (...sources: Array<Rx.BehaviorSubject<boolean>>) =>
|
||||||
|
Rx.combineLatest(sources.map(getValue$)).pipe(
|
||||||
filter((values) => values.every((v) => v === true)),
|
filter((values) => values.every((v) => v === true)),
|
||||||
take(1),
|
take(1),
|
||||||
mapTo(undefined)
|
mapTo(undefined)
|
||||||
|
@ -198,11 +201,24 @@ export class CliDevMode {
|
||||||
? Rx.EMPTY
|
? Rx.EMPTY
|
||||||
: Rx.timer(1000).pipe(
|
: Rx.timer(1000).pipe(
|
||||||
tap(() => {
|
tap(() => {
|
||||||
|
if (!optimizerReady$.getValue()) {
|
||||||
this.log.warn(
|
this.log.warn(
|
||||||
'please hold',
|
'please hold',
|
||||||
!optimizerReady$.getValue()
|
'optimizer is still bundling so requests have been paused'
|
||||||
? 'optimizer is still bundling so requests have been paused'
|
);
|
||||||
: 'server is not ready so requests have been paused'
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!serverReady$.getValue()) {
|
||||||
|
this.log.warn(
|
||||||
|
'please hold',
|
||||||
|
'Kibana server is not ready so requests have been paused'
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Error(
|
||||||
|
'user is waiting for over 1 second and neither serverReady$ or optimizerReady$ is false'
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue