ubuntudroid
11/03/2023, 10:01 AMAndroidViewModel
? I’m trying attachEventHandler()
, but still only the previous handler is called.
Background: I’m building with Compose and keep the ViewModel around longer than the screen, and I pass a SnackbarHostState
to the EventHandler to display snackbars. That also means that I need to regularly update the SnackbarHostState to match the currently used one and thus also the EventHandler.rocketraman
11/08/2023, 10:16 PMBallastNotification.ViewModelStarted
to send an initial input to the view model queue. What would the replacement be now that there is no ViewModelStarted
option. I see ViewModelStatusChanged
, and I can do if (it.status == Status.Running)
but I see that Status.Running
is in an internal package. Is there a better approach now?rocketraman
11/10/2023, 1:45 PMClosedSendChannelException
in the browser, after which my VMs stop working. Its not clear from the console log where the exception is coming from. Is it perhaps an incompatibility with Kotlin 1.9.20 -- 4.0.0 appears to be compiled against 1.9.10?Robert Jaros
11/10/2023, 2:14 PMrocketraman
11/10/2023, 4:45 PM/null
if going back past the top of the back stackS.
11/27/2023, 7:42 PMRobert Jaros
02/10/2024, 3:22 PMCasey Brooks
02/15/2024, 8:14 PMsigmadelta
02/18/2024, 8:31 PMbuild.gradle.kt
file are a bit different as opposed to prior KMM projects. And now when I try to add the ballast dependencies to my commonMain.dependencies
definition, the retrieval for the iOS targets fails (in the past, defining an ios()
was enough, now you need to be more specific e.g. iosArm64
, iosX64
, ...). When I move the dependencies to the androidMain
section however, the retrieval succeeds.
Is there something I'm missing in my gradle setup, or does the library need to define new target definitions to support these iOS sub-targets?Cherrio LLC
03/12/2024, 4:39 PMInputs.GoBack()
, data in the previous screen is lost.
Like if we had a query parameter in there before and we navigate back to the screen, there’s a null pointer exception that the parameter doesn’t exist
Is that intended??Cherrio LLC
03/20/2024, 4:00 PMRobert Jaros
05/17/2024, 6:04 AMCasey Brooks
05/20/2024, 4:29 PMballast-debugger-client
, since that depends on Ktor which does not yet have a stable release with WasmJS.
The only other notable change in this release is that ballast-navigation
no longer depends on ktor-http
, so it should result in a smaller binary for apps not using Ktor HTTP client. It is now using eygraber/uri-kmp for parsing URIs, which should just be an internal change and not require any updates to your codebase. However, there may be some differences in how the two libraries parse URIs, so if you notice any navigation URIs that worked in previous version but seem to not be handled correctly now, please let me know so I can fix it for you.Robert Jaros
06/02/2024, 12:58 PMIllegalStateException
and initialState required
message.Robert Jaros
06/02/2024, 1:09 PMRobert Jaros
06/02/2024, 1:10 PMRobert Jaros
06/02/2024, 1:59 PMbuild()
used in this class: https://github.com/rjaros/kvision/blob/master/kvision-modules/kvision-routing-ballast/src/jsMain/kotlin/io/kvision/routing/KVRouterViewModel.kt#L53dave08
06/27/2024, 3:11 PMRobert Jaros
07/01/2024, 12:31 PMsend
and sendAndAwaitCompletion
? Is using the latter somehow less performant?Casey Brooks
07/13/2024, 2:16 AMCherrio LLC
08/07/2024, 6:06 PMsigmadelta
09/10/2024, 9:11 PMRobert Jaros
09/18/2024, 10:42 AMsendToQueue(Queued.HandleInput(null, MyContract.MyInput(...)))
. Is this correct? What is the first parameter of HandleInput
- val deferred: CompletableDeferred<Unit>?
. Is passing null
ok?Mark Murphy
09/23/2024, 1:11 PMBasicTextField()
-- details in 🧵.Mark Murphy
09/25/2024, 1:20 PMwithRouter()
and BasicRouter
and instead building some sort of composite viewmodel? Or, is the vision that the I/O-handling viewmodel hold a reference to the router and tell it to navigate as needed? Or is there something else?
Thanks!sigmadelta
09/27/2024, 8:25 AMsigmadelta
10/15/2024, 3:41 PM// ... when (screen) { ...
AppScreen.Account,
AppScreen.AccountViewProfile -> {
val vm = remember { AccountScreenViewModel(scope) }
val state by vm.observeStates().collectAsState()
when (screen) {
AppScreen.Account -> AccountScreen(state) { vm.trySend(it) }
AppScreen.AccountViewProfile -> AccountViewProfileScreen(state)
else -> throw IllegalStateException("Can't have a different screen here for Account")
}
}
In this example I have a screen called Account
with a nested screen which shows more of the profile in details.
The problem is that I would like to persist (the state of) the ViewModel but as the recomposition happens, Compose creates a new instance of the ViewModel and the state gets cleared. So there are several ways to approach this issue that I thought of:
• Create a nested navigation where Appscreen.Account
is the main entry point and has several AccountScreen.xxx
destinations with its own router (did a similar thing for Login
)
• Persist the state and recreate when Account(ViewProfile)
is opened
• Move AccountViewModel
outside of recomposition space (will live in memory with app lifecycle so not ideal)
Is there a better approach I’m missing? I’ve also considered the option of using Ballast Sync, but I’ll basically have the same issues here as the Source (AccountViewModel
) will still be recreated with navigation.Mark Murphy
11/01/2024, 4:59 PMViewModel
and does work in onCleared()
. Two questions:
1. BasicViewModel
doesn't seem to offer onCleared()
or an equivalent. How do I know when the viewmodel is going out of scope, so I can do cleanup work there?
2. If I need to stick with Jetpack so I get an onCleared()
, and so therefore should use Ballast's AndroidViewModel
... how are we supposed to handle the CoroutineScope
? We're not supposed to use viewModelScope
, but it is unclear if we are on our own to cancel()
some other CoroutineScope
that we create. Do I just cancel()
it myself in onCleared()
?
Thanks!Mark Murphy
12/31/2024, 8:50 PMballast-test
to test observeFlows()
. I suspect that I'm just missing where/how to trigger the flow updates. Details in 🧵.Matthias
01/14/2025, 9:31 AM