abbic
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, 7:09 PMCasey Brooks
02/20/2023, 7:10 PMrememberCoroutineScope()
as the VM scope. This makes sure that a VM is only running when that part of the composition is actually needed, and releases those resources when the composition goes away.
For managing data across multiple screens, yes you’ll need to scope the VMs them to something more global than a point in the composition. I consider these “Repositories”, but the same Ballast MVI pattern works great for managing the data in your “Repository layer”abbic
02/20/2023, 7:11 PMCasey Brooks
02/20/2023, 7:13 PMsingle { }
in Koin would be a good way to do it. Those Repositories can then be injected into your UI ViewModels, but they all share the same instance and get updated whenever the Repository’s state changesabbic
02/20/2023, 7:14 PMCasey Brooks
02/20/2023, 7:17 PM