Queue like Subject in RxJava

前端 未结 3 1334
梦毁少年i
梦毁少年i 2020-12-29 06:06

I\'m looking for a Subject (or something similar) that can:

  1. Could receive items and hold them in a queue or buffer if there are no subscribers
  2. Once we
3条回答
  •  借酒劲吻你
    2020-12-29 06:40

    If you only want to wait for a single subscriber, use UnicastSubject but note that if you unsubscribe in the middle, all subsequent queued items will be lost.

    Edit:

    Once we have a subscriber all items are consumed and never emitted again

    For multiple subscribers, use ReplaySubject.

提交回复
热议问题