Builders, cold streams, and useful helpers for e.g. transforming data. Unlike LiveData, they are not bound to the lifecycle and offer more control over the execution context
StateFlow is a state-holder observable flow that emits the current and new state updates to its collectors.
The current state value can also be read through its value property. To update state and send it to the flow, assign a new value to the value property of the MutableStateFlow class.
inspired by https://medium.com/swlh/migrating-from-livedata-to-stateflow-4f28d6889a04
요약
LiveData 의 문제점
어디서나 쓸 수 있다. (repository layer)
Coroutine Flow
가 나옴. Excution context of Kotlin FlowssetValue() , postValue() 의 차이
value
변경을 바로 일으킬경우 UI Thread Exception 발생그래서 StateFlow 는 뭔가?
emits
: upstream (주고)collector
: downstream (받고)Flow Constraints(제약/준수 사항)
CodeLabLink
참고사항