我是rxjs的新手,并在Angular 5项目中使用"rxjs": "^5.5.6"
。
我有从不同位置导入zip的问题。
此代码可以正常工作:
import { Observable } from 'rxjs';
...
Observable.zip(
this.loadTexture('1.png'),
this.loadTexture('2.jpg'),
this.loadTexture('3.jpg'),
(t1, t2, t3) => ({ fairCloudsTexture: t1, noCloudsTexture: t2, elevBumpTexture: t3 })
).subscribe((textures) => {
this.fairCloudsTexture = textures.fairCloudsTexture;
this.noCloudsTexture = textures.noCloudsTexture;
this.elevBumpTexture = textures.elevBumpTexture;
this.initThreeJS();
});
但是当我使用此导入时,它不起作用:
import { zip } from 'rxjs/operators';
...
zip(
this.loadTexture('1.png'),
this.loadTexture('2.jpg'),
this.loadTexture('3.jpg'),
(t1, t2, t3) => ({ fairCloudsTexture: t1, noCloudsTexture: t2, elevBumpTexture: t3 })
).subscribe((textures) => {
this.fairCloudsTexture = textures.fairCloudsTexture;
this.noCloudsTexture = textures.noCloudsTexture;
this.elevBumpTexture = textures.elevBumpTexture;
this.initThreeJS();
});
这两个zip
方法之间有什么区别?为什么会出现此错误?
Property 'subscribe' does not exist on type 'UnaryFunction<Observable<{}>, Observable<{ fairCloudsTexture: {}; noCloudsTexture: {}; elevBumpTexture: {}; }>>'.ts(2339)