如何将所有数组添加到RXJ中的一个数组

发布于 2025-02-03 07:54:41 字数 323 浏览 1 评论 0原文

如何将所有数组添加到此代码的RXJ中的一个数组?

someObs$ = this.getSomeData$().pipe(
    mergeMap(res => res),
    groupBy(el => el.class),
    mergeMap(group$ => group$.pipe(toArray())),
    // how in this place create something like this: [[{},{}], [{},{}], [{},{}]]
    shareReplay(1)
  )

感谢您的帮助

how i can add all arrays to one in rxjs for this code?

someObs$ = this.getSomeData$().pipe(
    mergeMap(res => res),
    groupBy(el => el.class),
    mergeMap(group$ => group$.pipe(toArray())),
    // how in this place create something like this: [[{},{}], [{},{}], [{},{}]]
    shareReplay(1)
  )

Thanks for help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

将军与妓 2025-02-10 07:54:41

我找到了解决方案:操作员toarray()

I found solution for this: operator toArray()

月亮邮递员 2025-02-10 07:54:41

rxjs doc的定义 toarray operator:

toArray 将等到源可观察到的源后,然后发出包含所有排放的数组。当源时
可观察的错误不会发出数组。

大理石图:

RxJS Doc definition of toArray operator:

toArray will wait until the source Observable completes before emitting the array containing all emissions. When the source
Observable errors no array will be emitted.

Marble Diagram:
enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文