Ramzi Eljabali
07/08/2022, 9:05 PMThread 1: signal SIGABRT
when I run the iOS app on the following line
@ObservedObject
var observableModel = BallastObservable<
WeatherReportContract.Inputs,
WeatherReportContract.Events,
WeatherReportContract.ViewState>(
viewModelFactory: {KotlinDependencies.shared.getWeatherReportViewModel()}
//Highlights getWeatherReportViewModel
)
I also get Thread 1: signal SIGABRT
In the combine adapter used in the KaMPKit-ballast project
self.vmState = self.viewModelFactory().initialState //Line 58 highlights viewModelFactory
This is the contract I am using:
object WeatherReportContract {
data class ViewState(
val weatherReport: WeatherReport = WeatherReport(),
val isLoading: Boolean = false,
val errorMessage: String = ""
){
override fun toString(): String {
return "ViewState(" +
"Weather Report=${weatherReport::class.simpleName}, " +
"error=$errorMessage, " +
"isLoading=$isLoading" +
")"
}
}
sealed class Inputs {
object GetWeatherReport : Inputs()
object ShowLoading : Inputs()
object StopLoading : Inputs()
}
sealed class Events {
}
}
This is the iOSViewModel being used:
class WeatherReportViewModel(
weatherUseCase: WeatherUseCase,
configBuilder: BallastViewModelConfiguration.Builder
) : IosViewModel<
WeatherReportContract.Inputs,
WeatherReportContract.Events,
WeatherReportContract.ViewState
>(
config = configBuilder
.forViewModel(
initialState = WeatherReportContract.ViewState(),
inputHandler = WeatherReportInputHandler(weatherUseCase),
name = "WeatherReport"
)
)
This is the SwiftUI page:
import Combine
import SwiftUI
import shared
private let log = koin.loggerWithTag(tag: "ViewController")
struct WeatherReportView: View {
@ObservedObject
var observableModel = BallastObservable<
WeatherReportContract.Inputs,
WeatherReportContract.Events,
WeatherReportContract.ViewState>(
viewModelFactory: {KotlinDependencies.shared.getWeatherReportViewModel()}
)
var body: some View {
WeatherReportContent(
vmState: observableModel.vmState,
postInput: observableModel.postInput
).withViewModel(observableModel){
observableModel.postInput(WeatherReportContract.InputsGetWeatherReport())
}
}
}
struct WeatherReportContent: View {
var vmState: WeatherReportContract.ViewState
var postInput: (WeatherReportContract.Inputs) -> Void
var body: some View {
HStack(alignment: .center) {
VStack {
Text(vmState.weatherReport.cityTitle ).bold().font(TextStyle.headline.getFont())
Text(vmState.weatherReport.countryTitle ).bold()
Divider()
HStack(spacing: HorizontalSpacings.x10) {
Text(vmState.weatherReport.temperature )
Text(vmState.weatherReport.humidity )
}
.padding(SurroundingSpacings.large)
HStack(spacing: HorizontalSpacings.x10) {
Text(vmState.weatherReport.windSpeed )
Text(vmState.weatherReport.airPressure )
}
.padding(SurroundingSpacings.large)
}
.multilineTextAlignment(.center)
if vmState.isLoading {Text("Loading...")}
}
.font(TextStyle.body.getFont())
}
}
Here is the project branch, if you guys need a deeper look. Any help is greatly appreciated!Casey Brooks
07/08/2022, 9:15 PMkotlin.native.binary.memoryModel=experimental
to `gradle.properties. Here’s the official documentation for the new memory model as well https://github.com/JetBrains/kotlin/blob/master/kotlin-native/NEW_MM.md#enable-the-new-mmRamzi Eljabali
07/08/2022, 9:26 PMCasey Brooks
07/08/2022, 9:27 PMRamzi Eljabali
07/08/2022, 9:28 PM