forkJoin 不推荐用于多个可观察函数

问题描述

首先我有多个这样的服务文件 =>

services1.ts

Patch(updateobject:object,id:number): Observable<MyObject> {    
    return this.http.patch<MyObject>(`${this.MyObject_API}/${id}`,JSON.stringify(updateobject),{headers:{'Content-Type': 'application/json'}})           
   }

services2.ts

Patch(updateobject:object2,id:number): Observable<MyObject> {    
    return this.http.patch<MyObject>(`${this.MyObject2_API}/${id}`,{headers:{'Content-Type': 'application/json'}})           
   }

我试过喜欢=>

forkJoin(service1.patch(),service2.patch()).subscribe(([call1response,call2response])....

但为什么 forkJoin删除线而显示 forkJoin 已被弃用?

消息=>

(v1: ObservableInput<MyObject>,v2: ObservableInput<MyObject>): Observable<[MyObject,MyObject]>' is deprecated

解决方法

您必须使用数组作为参数:

forkJoin([service1.patch(),service2.patch()]).subscribe(([call1response,call2response])....