When should I use `publishReplay` vs `shareReplay`?

前端 未结 3 1344
青春惊慌失措
青春惊慌失措 2020-12-25 12:17

I already know that

  • publish shares a single subscription and also returns a ConnectableObservable ( so we have to Connect(

3条回答
  •  甜味超标
    2020-12-25 13:02

    shareReplay() is basically publishReplay().refCount()

    Here is a great article explaingin just that in detail: "Angular Async Pipes  - Beware the share"

    Edit:

    The right thing to say is:

    shareReplay() is similar to publishReplay().refCount()

    see @DevRok's answer for more info why they are not exactly the same.

提交回复
热议问题