https://kotlinlang.org logo
Title
i

iamsteveholmes

04/07/2021, 5:52 PM
I've been working through the samples for my own project. At the moment my view doesn't appear to access the data from the model on Ios/SwiftUI at least from the preview screen. I'm a little confused where the ViewModel and ViewEvents come from on IOS. Are they generated? For instance, from the example:
import Foundation
import TodoLib

class TodoListViewProxy: BaseMviView<TodoListViewModel, TodoListViewEvent>, TodoListView, ObservableObject {
    
    @Published var model: TodoListViewModel?
    
    override func render(model: TodoListViewModel) {
        self.model = model
    }
}
Where is the TodoListViewModel generated? If I set up a preview here and there was data being accessed from the model (using sqldelight in this case), would we expect the preview to show the data?
You can also consider this sample: https://github.com/JetBrains/compose-jb/tree/master/examples/todoapp It also uses SwiftUI in iOS, but it also uses Decompose for shared navigation logic, so clients' integration parts (iOS, Android, etc) are simpler. E.g. there is no such a thing as
ViewProxy
, and you don't need to deal with
NavigationLink
etc.
i

iamsteveholmes

04/08/2021, 12:36 AM
Thanks for answering quickly! I see the interface but where is the implementing class for TodoListViewModel?
By the way, watched this video:

https://www.youtube.com/watch?v=pjcUBQwcdfo

Thanks for all your work on these projects!
🎉 1
a

Arkadii Ivanov

04/08/2021, 8:20 AM
Implementation is presented in your snippet. The Model and Event classes are defined inside the interface. TodoListViewModel is same as TodiListView.Model, it is just how inner classes are exported to Swift by Kotlin/Native.
i

iamsteveholmes

04/08/2021, 5:17 PM
Ohhhhh...Okay that was something I definitely didn't know. I've read through various docs but I must be missing something out of the Kotlin Native docs
Thanks!
a

Arkadii Ivanov

04/08/2021, 6:28 PM
Yeah, looks like this information is missing in the docs. 😐