Ramzi Eljabali

06/25/2022, 12:34 PM
Is it possible to have a shared VM between Android and iOS using Ballst?

Casey Brooks

06/27/2022, 2:44 PM
You can absolutely set one up with actual/expect declarations, if that fits your application structure. It’s difficult because the ViewModel implementations can be so different in terms of what’s passed to their constructor, when to attach EventHandlers (because of the platform’s lifecycle), and things like that, but you can definitely make your life a bit easier with an actual/expect VM if your app allows for that. Alternatively, you could define your “ViewModel” as an interface or typealias and pass it around with dependency injection in common code, and provide the concrete implementation for the DI in each platform. That said, the intention was to keep the actual ViewModel class as pretty much pure boilerplate which can be easily generated by the IntelliJ plugin, so that it’s not so necessary to have an actual “shared VM”. All the important stuff is going to be in the Contract, InputHandler, etc. that is already in the shared code
👍 1

Ramzi Eljabali

06/29/2022, 11:37 PM
Awesome, thanks @Casey Brooks!