dan.the.man
08/20/2022, 9:19 PM@Composable
fun showList(actions:MutableSharedFlow<Action>){
val scope = rememberCoroutineScope()
Box(contentAlignment = Alignment.Center) {
Column(Modifier.clickable {
scope.launch { actions.emit(NewEvent())}
This works, but if I navigate back to the page, and repeat the action, the event fires 2x, and then 3x if I navigate back etc. What am I missing here? Changing it to a method that's passed in instead of creating a lambda results in what I'd expect
@Composable
fun showList(actions:(Action) -> Unit){
val scope = rememberCoroutineScope()
Box(contentAlignment = Alignment.Center) {
Column(Modifier.clickable {
actions(NewEvent())
^ that works, I guess it has to do with stable?Zach Klippenstein (he/him) [MOD]
08/21/2022, 7:01 PMdan.the.man
08/21/2022, 7:02 PMZach Klippenstein (he/him) [MOD]
08/21/2022, 7:04 PMdan.the.man
08/21/2022, 7:05 PMfun showFragment(fragment: Fragment){
supportFragmentManager.beginTransaction().replace(R.id.content, fragment, null).addToBackStack(null)).commit()
}
With one activityoverride fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View {
return ComposeView(requireContext()).apply {
setContent {
MyScreen(viewModel){
sendAction(it)
}
}
}
Is the current iteration, before I was passing the SharedFlow in hereZach Klippenstein (he/him) [MOD]
08/21/2022, 7:07 PMdan.the.man
08/21/2022, 7:07 PMLeland Richardson [G]
08/21/2022, 9:04 PM