Open Ly41k opened 7 months ago
I have the same issue but the solution you proposed is not working
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() } } } }
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 useMutableSharedFlow<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