lazt omen
01/02/2023, 1:34 PMCasey Brooks
01/04/2023, 5:42 PMRobert Jaros
01/06/2023, 1:17 PMAndromadus Naruto
01/10/2023, 9:58 PMCasey Brooks
01/11/2023, 5:26 PMAdrian Witaszak
01/16/2023, 9:02 AMcommonMain
using the Jetbrains Compose. Do you have any recommendations for using Ballast in this use case? Expect/Actuals for ViewModels?Adrian Witaszak
01/16/2023, 7:07 PMAdrian Witaszak
01/17/2023, 9:21 AMonGoBack: () -> Unit
Casey Brooks
01/20/2023, 4:43 PMAdrian Witaszak
02/13/2023, 10:31 AMAdrian Witaszak
02/13/2023, 2:59 PMAdrian Witaszak
02/13/2023, 3:03 PMAdrian Witaszak
02/13/2023, 3:06 PMAdrian Witaszak
02/13/2023, 3:09 PMAdrian Witaszak
02/13/2023, 3:56 PMAdrian Witaszak
02/13/2023, 3:56 PMAdrian Witaszak
02/13/2023, 3:58 PMAdrian 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
))
}
ayodele
02/13/2023, 8:37 PMAdrian Witaszak
02/13/2023, 11:08 PMAdrian Witaszak
02/13/2023, 11:14 PMAndromadus Naruto
02/14/2023, 11:06 PMabbic
02/19/2023, 8:48 PMclass RouterViewModel(
viewModelCoroutineScope: CoroutineScope
) : BasicRouter<AppRoutes>(config = BallastViewModelConfiguration.Builder())
there's an error on BasicRouter because the <init> is private on BasicViewModel. additionally it claims to not find the config field. Clearly this is strange as BasicViewModel has a public secondary constructor defined right there where i can see it. am on ballast 2.3.3abbic
02/20/2023, 4:39 PMconfig = viewModelConfig {
withRouter(...)
}
just as an exampleabbic
02/20/2023, 7:03 PMsingle { CoroutineScope(<http://Dispatchers.IO|Dispatchers.IO> + SupervisorJob()) }
that should make it easy to similarly provide ballast components with koin, which require this coroutine scope?
im worrying because it seems like compose scope is great for managing the lifecycle of components like viewmodels already (leaving the composition discards the instance), so maybe koin is overkill for thisabbic
02/20/2023, 10:10 PMPostListScreen(
sort = sort,
onPostSelected = { postId: Long ->
// The user selected a post within the PostListScreen. Generate a URL which will match
// to the PostDetails route, by using its directions to ensure the right parameters are
// provided in the URL
router.trySend(
RouterContract.Inputs.GoToDestination(
AppScreen.PostDetails
.directions()
.pathParameter("postId", postId.toString())
.build()
)
)
},
)
and that could work, in fact i do something very similar on android, but it doesnt feel idiomatic to ballast? for example if we wanted to navigate not directly from a ui click (and in fact, from what i understand of ballast, it would be weird to drive anything from the ui except an Input
anyway), but instead drive a navigation event from business logic, we would still have to pass this navigation lambda to the event handler manually.
should i provide the router through a single {}
and inject it into the event handler? maybe with an interface that only exposes navigation routes available on this screen?abbic
02/25/2023, 11:12 AMval AppScope = CoroutineScope(window.asCoroutineDispatcher())
which is a browser thing, but it also makes me wonder what would happen if this coroutine was cancelled for any reason (at a guess, the window as coroutine dispatcher prevents that from happening?)rocketraman
02/27/2023, 8:03 PMabbic
03/01/2023, 12:35 PMrocketraman
03/17/2023, 5:36 PMrocketraman
03/17/2023, 5:36 PMCasey Brooks
03/17/2023, 6:03 PMrocketraman
03/17/2023, 6:14 PMCasey Brooks
03/17/2023, 6:19 PMrocketraman
03/17/2023, 6:21 PMPlease note that not all target platforms have reached this level of stability (but Kotlin/JVM has).