[cli-dev-mode] complete state subjects when shutting down (#96003)

Co-authored-by: spalger <spalger@users.noreply.github.com>
This commit is contained in:
Spencer 2021-04-01 07:01:59 -07:00 committed by GitHub
parent 9c5641dbd7
commit 3187567a0e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 8 deletions

View file

@ -249,5 +249,11 @@ export class DevServer {
)
.subscribe(subscriber)
);
// complete state subjects when run$ completes
subscriber.add(() => {
this.phase$.complete();
this.ready$.complete();
});
});
}

View file

@ -180,6 +180,7 @@ it('is ready when optimizer phase is success or issue and logs in familiar forma
"ready: false",
"<issue>",
"ready: true",
"complete",
]
`);

View file

@ -107,14 +107,26 @@ export class Optimizer {
},
]);
this.run$ = runOptimizer(config).pipe(
logOptimizerState(log, config),
tap(({ state }) => {
this.phase$.next(state.phase);
this.ready$.next(state.phase === 'success' || state.phase === 'issue');
}),
ignoreElements()
);
this.run$ = new Rx.Observable<void>((subscriber) => {
subscriber.add(
runOptimizer(config)
.pipe(
logOptimizerState(log, config),
tap(({ state }) => {
this.phase$.next(state.phase);
this.ready$.next(state.phase === 'success' || state.phase === 'issue');
}),
ignoreElements()
)
.subscribe(subscriber)
);
// complete state subjects when run$ completes
subscriber.add(() => {
this.phase$.complete();
this.ready$.complete();
});
});
}
getPhase$() {

View file

@ -103,6 +103,11 @@ export class Watcher {
.pipe(ignoreElements())
.subscribe(subscriber)
);
// complete state subjects when run$ completes
subscriber.add(() => {
this.restart$.complete();
});
});
serverShouldRestart$() {