[Kotlin] Flow Quick Note 이글은 medium의 19 Things to Know About Kotlin Flow - A Quick Note를 번역 및 의역한 글입니다.[1] https://blog.canopas.com/19-things-to-know-about-kotlin-flow-a-quick-note-1b90eb74f3b0 19 Things to know about Kotlin Flow — A quick note Flow is an asynchronous data stream that sequentially emits values and completes normally or with an exception. (We already know this very… blog.canopas.com 필요한 경우 위 링크에서 원문 확인이 .. 개발이야기/Kotlin 3년 전
[Coroutine] State flow vs Shared flow with case study Flow를 사용하면서 유용하게 사용할 수 있는 state flow와 shared flow가 다른 점과 각각 어떤 상황에서 적합한지를 알기 위하여 두 개의 특성을 비교하려고 합니다. Flow builder로 생성한 flow들은 기본적으로 Cold stream 입니다.[2] 하지만 StateFlow와 SharedFlow는 둘다 Hot stream입니다. 이해를 돕기 위해 두 stream을 간단히 비교하면 아래와 같습니다. Cold stream collect() (또는 이를 subscribe 할 때)를 호출할 때마다 flow block이 재실행 된다. 즉 1~10까지 emit 하는 flow가 있다면 collect 할때마다 1~10을 전달 받는다. 여러곳에서 collect를 호출하면 각각의 collect에서 1.. 개발이야기/Kotlin 3년 전