Adrian Witaszak
02/13/2023, 8:19 PM20:15:18.730 W BallastException(_cause=java.lang.IllegalStateException: This InputHandlerScope has already been closed, handled=true, latestState=State(isUserSignedIn=false), inputSequence=[src.txconnected.mobox.shared_ui.component.root.RootContract$Inputs$ObserveUserState@ce9ec24])
Here is my input:
RootContract.Inputs.ObserveUserState -> observeFlows(
"observeUserState",
flow {
while (true) {
postInput(RootContract.Inputs.CheckUserState)
}
}
)
RootContract.Inputs.CheckUserState -> postInput(
RootContract.Inputs.ChangeUserSignInState(
SDK.sessionManager.isLoggedIn
)
)
is RootContract.Inputs.ChangeUserSignInState -> updateState {
it.copy(isUserSignedIn = input.newState)
}
}
And i start it in the RootContent:
internal fun RootContent(
) {
val coroutineScope = rememberCoroutineScope()
val snackbarHostState = remember { SnackbarHostState() }
val vm = remember(coroutineScope) {
RootViewModel(
viewModelCoroutineScope = coroutineScope,
displayErrorMessage = { snackbarHostState.showSnackbar(it) },
)
}
val state by vm.observeStates().collectAsState()
vm.trySend(RootContract.Inputs.ObserveUserState)
RouterContent(state.isUserSignedIn)
}
In router gets false will got back to Login page:
internal fun RouterContent(isSignedIn: Boolean) {
val scope = rememberCoroutineScope()
val router: Router<RouterScreens> = remember(scope) {
RouterViewModel(scope,)
}
val routerState: Backstack<RouterScreens> by router.observeStates().collectAsState()
if (!isSignedIn) {
router.trySend(RouterContract.Inputs.ReplaceTopDestination(
RouterScreens.Login.matcher.routeFormat
))
}
Casey Brooks
02/13/2023, 8:26 PMObserveUserState
because you’re calling postInput
instead of emit
. This is breaking the intended DSL scoping.
Do this instead:
observeFlows(
"observeUserState",
flow {
while (true) {
emit(RootContract.Inputs.CheckUserState)
}
}
)
or else drop the Flow and call postInput
from within a sideJob()
sideJob("observeUserState") {
while (true) {
postInput(RootContract.Inputs.CheckUserState)
}
}
Adrian Witaszak
02/13/2023, 8:28 PMCasey Brooks
02/13/2023, 9:13 PMBallastLogger
instance, and manually filter the logs from there, or just configure your log viewer to exclude logs containing CheckUserState
. Logging in Ballast is very basic and relies more on filtering from your chosen Logging library instead of implementing that level of log fidelity in the library.