kviewmodel--mpp icon indicating copy to clipboard operation
kviewmodel--mpp copied to clipboard

Action does not work correctly

Open Ly41k opened this issue 2 years ago • 2 comments

Problem: When I try to go back to the previous screen - I get the previous Action again

Solution: I think the error is in this line: private val _viewActions = MutableSharedFlow<Action?>(replay = 1, onBufferOverflow = BufferOverflow.DROP_OLDEST) - we specified replay = 1, for one-time events it is better to use MutableSharedFlow<Action?>(extraBufferCapacity = 1, onBufferOverflow = BufferOverflow.DROP_OLDEST)

Then everything works correctly

https://github.com/adeo-opensource/kviewmodel--mpp/assets/59660150/3bceedc1-a56b-43f1-8df0-22d904b5201e

Ly41k avatar Jan 19 '24 09:01 Ly41k

I have the same issue but the solution you proposed is not working

ilhomsoliev avatar May 23 '24 17:05 ilhomsoliev

I do it this way for it to work:

LaunchedEffect(viewAction.value) { viewAction.value?.let { when (it) { LoginAction.OpenHome -> openCodeScreen(viewState.phone) LoginAction.GoBack -> { "Comes here action".printToLog() onBack() } } } }

ilhomsoliev avatar May 23 '24 17:05 ilhomsoliev