将flatmap和forkjoin组合在一个调用角度中

时间:2018-02-16 14:48:56

标签: angular nested fork-join flatmap

我必须做5个api调用,前2个按顺序而不是其他2个并行,最后一个跟在2之后并行,我试图使用flatmap + forkjoin但似乎是不可能在一个电话中组合所有 还有其他替代方式吗?

我的代码就是这个......

public wrapfuncPOAddHead(response: any): Observable<any> {
    this.parsePOBatches(response.data)
    const request1 = this.createRequestAddHead();
    return this.widgetContext.executeIonApiAsync<IMIResponse>(request1)
}

public wrapfuncPOAddLine(response: any): Observable<any> {
    this.parsePOAddHead(response.data)
    const request2 = this.createRequestAddLine();
    return this.widgetContext.executeIonApiAsync<IMIResponse>(request2)
}


public createPO(suno: string, itno: string): void {

    this.setBusy(true);
    const request = this.createRequestBatchOrigin();
    this.widgetContext.executeIonApiAsync<IMIResponse>(request)
        .mergeMap(response => this.wrapfuncPOAddHead(response))
        .subscribe(response => response),
        (error) => this.showErrorMessage(error)
}

我会在forkjoin中调用wrapfuncAddLine吗? 我怎么能这样做?

谢谢

0 个答案:

没有答案