我有以下代码
我是rjxs编程的新手,所以想知道根本原因是什么。我正在尝试做一个特定的任务,首先合并所有最新的结果,然后订阅分配结果。但combineLatest似乎不能正常工作。可能的原因是什么?
const downloadUrls$: any = Array.from(event.target.files).map((file: any) => {
const fileName = ...
const path = ...
const fileRef = ....
const task: any = ...
return task.snapshotChanges().pipe(
filter(snap => snap.state === firebase.storage.TaskState.SUCCESS),
switchMap(() => {
return fileRef.getDownloadURL().pipe(
map((url: string) => ({
name: fileName,
filepath: url,
relativePath: path,
}))
);
})
);
});
combineLatest(...downloadUrls$).subscribe((urls: any) => {
console.log(hi); // not printing
});发布于 2020-04-22 17:46:38
组合测试不会触发的原因是主题的引用。您应该更改为此版本。所以移除..。在下载before $之前。
combineLatest(downloadUrls$).subscribe((urls: any) => {
console.log(hi); // not printing
});Combinelatest用于合并两个或更多可观察对象。对一个观察值使用组合测试有什么特别的原因吗?否则,您可以更改为更简单的版本,如
downloadUrls$.subscribe((urls: any) => {
console.log(hi); // not printing
});发布于 2020-04-23 02:09:38
最新版本的cobineLateste()接收一个数组作为参数:
combineLatest(downloadUrls$).subscribe((urls: any) => {
console.log(hi); // not printing
});https://stackoverflow.com/questions/61361838
复制相似问题