Wait for observable to complete

You might try something like this...

main(data: string) : string {

    process1Data$: Observable<string> = process1(data)
        .take(1)
        .switchMap((process1Data) => return process2(process1Data);
    .
    .
    .
}

Obviously, take(1) assumes that process1(...) resolves to single value and stops. After that it switchMaps to process2 which means it starts emitting whatever observable from process2 gives. If, on the other hand, you want process2 to be ran of each result emitted from process1 then just remove take(1).


You can use rxjs concat operator. See documentation here. concat

Basically it waits untill the first or source observable returns and then executes next.

update

You can also try operators like switch or switchmap according to your requirements.