Thread
#compose
    James Black

    James Black

    1 year ago
    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) }
    m

    miqbaldc

    1 year ago
    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
    James Black

    James Black

    1 year ago
    Thanks let me check it out.