Difference between `share()` and `publish().refCount()`

后端 未结 2 1608
悲&欢浪女
悲&欢浪女 2021-02-07 15:02

What\'s the practical difference between observable.publish().refCount() and observable.share(). What would be an example of an scenario in which we do

2条回答
  •  眼角桃花
    2021-02-07 15:12

    According to article "Rxjs Observable publish refcount vs share";

    With observable.publish().refCount(), once the observer completes, it will not restart if a new subscriber is added after completion. Whereas with observable.share(), if the underlying observer completes and a new subscriber is added later, the observer effectively begins a new execution and starts emitting data.

提交回复
热议问题