ReplaySubject(1)是否与AsyncSubject()相同?

编程入门 行业动态 更新时间:2024-10-28 03:23:11
本文介绍了ReplaySubject(1)是否与AsyncSubject()相同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我当前正在使用它来执行通知:

I'm currently using this to perform notifications:

/** * Create notifications that broacast * the entire set of entries. */ protected notify = new ReplaySubject<E[]>(1);

IIUC我可以用 AsyncSubject< E []>()切换 ReplaySubject< E []> 吗?

IIUC I can switch out the ReplaySubject<E[]>(1) with AsyncSubject<E[]>()?

这将是苹果到苹果的转换,还是语义上的差异?

Would this be an apple to apple switch or might here be semantic differences?

推荐答案

不,它们非常不同.

ReplaySubject(1)将始终重播最新的发射,无论观察者何时订阅.它可以发射任意次.

ReplaySubject(1) will always replay the latest emission no matter when the observer subscribes. It can emit any number of times.

AsyncSubject忽略所有发射,直到可观察值完成为止,然后发射最后一个发射值.它只能发射一次(最多),当发射一次时,它也会完成.

AsyncSubject ignores all emissions until the observable completes, then emits the last emitted value. It can only ever emit once (at most) and when it does, it will also complete.

更多推荐

ReplaySubject(1)是否与AsyncSubject()相同?

本文发布于:2023-11-12 07:02:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1580831.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:ReplaySubject   AsyncSubject

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!