Skip to content

Commit

Permalink
[cli-dev-mode] get values from completed state subjects (#107428)
Browse files Browse the repository at this point in the history
Co-authored-by: spalger <[email protected]>
Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
3 people authored Aug 3, 2021
1 parent 48a97f6 commit 3d8a2cf
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions packages/kbn-cli-dev-mode/src/cli_dev_mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,11 @@ export interface CliDevModeOptions {
cache: boolean;
}

const firstAllTrue = (...sources: Array<Rx.Observable<boolean>>) =>
Rx.combineLatest(sources).pipe(
const getValue$ = <T>(source: Rx.BehaviorSubject<T>): Rx.Observable<T> =>
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)),
take(1),
mapTo(undefined)
Expand Down Expand Up @@ -198,11 +201,24 @@ export class CliDevMode {
? Rx.EMPTY
: Rx.timer(1000).pipe(
tap(() => {
this.log.warn(
'please hold',
!optimizerReady$.getValue()
? 'optimizer is still bundling so requests have been paused'
: 'server is not ready so requests have been paused'
if (!optimizerReady$.getValue()) {
this.log.warn(
'please hold',
'optimizer is still bundling 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'
);
})
)
Expand Down

0 comments on commit 3d8a2cf

Please sign in to comment.