Comment attendre l'abonnement pour terminer avant de revenir à la méthode de l'appelant en Angular

save(job: Model, status: string) {
    console.log('Starting apiService.serviceMethod');
    this.apiService.serviceMethod(job, status).pipe(
        switchMap((job: Model) => {
            if (job) {
                // Some update of job is require here since the GET call doesn't know 
                // whereas the UI does. 
                // Modify job variable here.
            
                console.log('Starting PUT call');
                return this.apiService.updatePutMethod(job); 
            } else {
                console.log('Skipping PUT call');
                return of(null);
            }
        })
    ).subscribe(() => {
        console.log("Ready to emit");
        this.notify.emit('Saved!');
    });
}


import { of } from 'rxjs';

serviceMethod(job: Model, status: string): Observable<Model> {
    if (status && (status === 'Publish' || status === 'UnPublish')) {
        console.log('Staring POST call');
        return this.firstPostMethod(task).pipe(
            switchMap((task) => {
                console.log('Starting GET call');               
                return this.firstGETCall(task);
            })
        );
    } else {
        // either status is null/empty or does not equal either of the strings.
        return of(null);
    }
}
SAMER SAEID