본문 바로가기

공부/RxJava

Cold / Hot Observable

http://reactivex.io/documentation/observable.html

When does an Observable begin emitting its sequence of items? It depends on the Observable. A “hot” Observable may begin emitting items as soon as it is created, and so any observer who later subscribes to that Observable may start observing the sequence somewhere in the middle. A “cold” Observable, on the other hand, waits until an observer subscribes to it before it begins to emit items, and so such an observer is guaranteed to see the whole sequence from the beginning.

Hot Observable

  • 번역 : "Hot" Observable은 생성되자마자, emit을 시작하고, 나중에 구독하는 Observer는 중간에 언제든 관찰을 시작할 수 있습니다.
  • 비유 : 실시간 방송 - 시청자(observer)가 보든 말든 방송을 시작 ->  시청자는 subscribe하는 시점부터 시청 가능(event)

Cold Observable

  • 번역 : "Cold" Observable은 Observer가 구독할 때까지 대기하고 item을 emit하므로, Observer는 처음부터 전체 시퀀스를 볼 수 있습니다.
  • 비유 : 녹화방송 - 시청자가 보기 시작한 순간 부터 처음부터 시작