Created
March 1, 2021 11:21
-
-
Save raulh82vlc/016560afc489172519712ab94338a2fa to your computer and use it in GitHub Desktop.
SearchStateHandler collects state and passes it directly to the SearchComposablesUI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ActivityScope | |
class SearchStateHandler @Inject constructor(@Named("CoroutineUIScope") private val scope: CoroutineScope) { | |
private var searchComposablesUI: SearchComposablesUI? = null | |
private lateinit var stateFlow: StateFlow<TweetsUIState> | |
fun initStateFlowAndViews( | |
val stateFlow: StateFlow<TweetsUIState>, | |
val searchComposablesUI: SearchComposablesUI | |
) { | |
this.stateFlow = stateFlow | |
this.searchComposablesUI = searchComposablesUI | |
} | |
fun processStateCollection() { | |
stateFlow.onEach { uiState -> | |
searchComposablesUI?.startComposingViews(uiState) | |
}.launchIn(scope) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment