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
miqbaldc
07/18/2021, 3:35 AM
The
viewEvents
part is where you add the compose ui
miqbaldc
07/18/2021, 3:35 AM
But didn't sure about the recomposition if added inside a collected events