mirror of
				https://github.com/avatao-content/frontend-tutorial-framework
				synced 2025-10-31 02:32:55 +00:00 
			
		
		
		
	Refactor ProcessManagerService error and success callback semantics
This commit is contained in:
		| @@ -74,11 +74,9 @@ export class IdeComponent implements OnInit { | |||||||
|  |  | ||||||
|   initProcessManagerService() { |   initProcessManagerService() { | ||||||
|     this.processManagerService.init(); |     this.processManagerService.init(); | ||||||
|     this.processManagerService.subscribeCallback(config.ide.deployProcessName, (event) => { |     this.processManagerService.subscribeCallback(config.ide.deployProcessName, (event) => this.deploymentNotificationService.deploying.next(false)); | ||||||
|        this.setDeployButtonState('DEPLOYED'); |     this.processManagerService.subscribeSuccessCallback(config.ide.deployProcessName, (event) => this.setDeployButtonState('DEPLOYED')); | ||||||
|        this.deploymentNotificationService.deploying.next(false); |     this.processManagerService.subscribeErrorCallback(config.ide.deployProcessName, (event) => this.setDeployButtonState('FAILED')); | ||||||
|       }); |  | ||||||
|     this.processManagerService.subscribeErrorCallback(config.ide.deployProcessName, (event) => { this.setDeployButtonState('FAILED'); }); |  | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   updateFileData(data: SourceCode) { |   updateFileData(data: SourceCode) { | ||||||
|   | |||||||
| @@ -24,6 +24,10 @@ export class ProcessManagerService { | |||||||
|     this.observeProcessMessage(process_name).subscribe(callback); |     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) { |   subscribeErrorCallback(process_name: string, callback: (event: WSMessage<ProcessCommand>) => void) { | ||||||
|     this.observeProcessMessage(process_name).pipe(filter(message => 'error' in message.data)).subscribe(callback); |     this.observeProcessMessage(process_name).pipe(filter(message => 'error' in message.data)).subscribe(callback); | ||||||
|   } |   } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user