Cold flow (như flow {} hay PagingSource) chỉ phát giá trị khi có collector và bắt đầu lại từ đầu cho mỗi collector.
- Hot flow (như
StateFlow,SharedFlow) phát giá trị bất kể có collector hay không và chia sẻ cùng một stream.StateFlowlà hot flow có current value — dùng cho state.Flowthông thường là cold — dùng cho luồng event. - Hot flow hiệu quả bộ nhớ hơn khi có nhiều collector.
Cold flows (like flow {} or PagingSource) only produce values when collected and start from the beginning for each collector.
- Hot flows (like
StateFlow,SharedFlow) emit values regardless of collectors and share the same stream.StateFlowis hot with a current value — use it for state. - Regular
Flowis cold — use for event streams. - Hot flows are more memory-efficient for multiple collectors.