Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cold Observable과 Hot Observable #5

Closed
seungchan2 opened this issue May 22, 2022 · 0 comments
Closed

Cold Observable과 Hot Observable #5

seungchan2 opened this issue May 22, 2022 · 0 comments
Assignees
Labels
New 새로 알게 된 것입니다.

Comments

@seungchan2
Copy link
Owner

seungchan2 commented May 22, 2022

Hot Observable

Observable이 언제 어떤 순서의 아이템을 방출하는 지는 Observable에 달려있는데

Hot Observable은 생성되는 즉시 방출하기 시작하는데 이 때, 중간의 아이템을 방출하고 있더라도 그 아이템을 방출함

간단히 말해서, Hot Observable은 구독하는 순간부터 시퀀스의 중간 아이템을 방출하더라도 그 순간부터의 이벤트를 전달함

Cold Observable

Cold Observable은 Observer가 구독할 때까지 기다리고 구독하는 순간부터 방출

Observer에게 방출하는 아이템의 전부를 볼 수 있게 보장함

Cold Observer구독하는 순간에 시퀀스의 처음부터 끝까지의 이벤트를 전부 전달함

간단한 예시를 통해 살펴보겠음

Hot Observable

실시간 Live Streaming 방송을 함

우리가 언제든 방송에 입장하게 되면 방송이 처음에 시작 됐을 때 부터가 아닌 현재 방송중인 시점부터 방송을 받아볼 수 있잖슴?

RxSwift에서 Hot Observable은 Timer, Subject, UIEvent 같은 것들이 있음

여러 구독자가 data를 공유할 수 있음

data가 생산될 때 구독자가 없으면 해당 데이터를 잃어버리게 됨

Cold Observable

VOD를 예시로 들 수 있음

언제부터 시청을 하더라도 처음부터 끝까지 원하는 부분을 시청하는 것이 가능하잖슴?

뭐 넷플릭스, 왓챠, 유튜브 등이 있겠죠?

RxSwift에서 Single, just, of 등등의 컴포넌트이 있음

각각의 구독자가 Observable을 실행하면 data는 공유되지 않음

Observable이 구독자마다 새로운 실행을 하기 때문에 구독자마다 값이 모두 달라짐

@seungchan2 seungchan2 added the New 새로 알게 된 것입니다. label May 22, 2022
@seungchan2 seungchan2 self-assigned this May 22, 2022
@seungchan2 seungchan2 changed the title Cold, Hot Observable-Disposed가 되는 때 Cold Observable과 Hot Observable May 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New 새로 알게 된 것입니다.
Projects
None yet
Development

No branches or pull requests

1 participant