Refactor ProcessManagerService error and success callback semantics

This commit is contained in:
Kristóf Tóth 2018-05-18 10:28:14 +02:00
parent 5ebe29ccc8
commit 4b79d77fcc
2 changed files with 7 additions and 5 deletions

View File

@ -74,11 +74,9 @@ export class IdeComponent implements OnInit {
initProcessManagerService() {
this.processManagerService.init();
this.processManagerService.subscribeCallback(config.ide.deployProcessName, (event) => {
this.setDeployButtonState('DEPLOYED');
this.deploymentNotificationService.deploying.next(false);
});
this.processManagerService.subscribeErrorCallback(config.ide.deployProcessName, (event) => { this.setDeployButtonState('FAILED'); });
this.processManagerService.subscribeCallback(config.ide.deployProcessName, (event) => this.deploymentNotificationService.deploying.next(false));
this.processManagerService.subscribeSuccessCallback(config.ide.deployProcessName, (event) => this.setDeployButtonState('DEPLOYED'));
this.processManagerService.subscribeErrorCallback(config.ide.deployProcessName, (event) => this.setDeployButtonState('FAILED'));
}
updateFileData(data: SourceCode) {

View File

@ -24,6 +24,10 @@ export class ProcessManagerService {
this.observeProcessMessage(process_name).subscribe(callback);
}
subscribeSuccessCallback(process_name: string, callback: (event: WSMessage<ProcessCommand>) => void) {
this.observeProcessMessage(process_name).pipe(filter(message => !('error' in message.data))).subscribe(callback);
}
subscribeErrorCallback(process_name: string, callback: (event: WSMessage<ProcessCommand>) => void) {
this.observeProcessMessage(process_name).pipe(filter(message => 'error' in message.data)).subscribe(callback);
}