https://kotlinlang.org logo
#compose
Title
# compose
j

James Black

07/17/2021, 5:58 PM
I am trying to use model-view-intent but have something not certain how to do. Basically I have Row { Button(onClick = { Log.d("UpvoteView", "heart pressed") }) { Text("+❤️") } I have this. fun View.clicks(): Flow<Unit> = callbackFlow { val listener = View.OnClickListener { this.trySend(Unit).isSuccess } setOnClickListener(listener) awaitClose { setOnClickListener(null) } } How can I get ‘clicks’ to work in the onclick function for the button? ‘This’ is for rowscope I learned. I would like to do something like this in a way that works with compose. override fun viewEvents(): Flow<MainViewEvent> { val flows = listOf( heartButton.clicks().map { MainViewEvent.LoveItClick }, thumbButton.clicks().map { MainViewEvent.ThumbsUpClick }, cloudButton.clicks().map { MainViewEvent.CloudClick(scope) } ) return flows.asFlow().flattenMerge(flows.size) }
🧵 4
m

miqbaldc

07/18/2021, 3:34 AM
You might wanna see an example from uniflow
The
viewEvents
part is where you add the compose ui
But didn't sure about the recomposition if added inside a collected events
j

James Black

07/18/2021, 3:33 PM
Thanks let me check it out.
6 Views