Saad
12/19/2024, 3:09 AMsealed class UiState<out T> {
data object Loading : UiState<Nothing>()
data class Success<T>(val data: T) : UiState<T>()
data class Error(val message: String) : UiState<Nothing>()
}
and I have a viewModel
I have in Swift using the observable protocol:
@MainActor
class ContentViewModel: ObservableObject {
let profile = MyProfile()
@Published
private(set) var currentState: UiState<RawProfile> = ...
func observeProfile() async {
for await state in self.profile.profileData {
self.currentState = state
}
}
}
I want to initialize currentState
with UiState.Loading
But I can't seem to figure out the syntax to fill in the ...
Any help would be very much appreciated!Tadeas Kriz
12/19/2024, 3:13 PMUiStateLoading.shared
. If your Kotlin framework is called shared
, SKIE has to rename the .shared
to .shared_
so it might be UiStateLoading.shared_
instead.Saad
12/19/2024, 4:05 PMUiStateLoading.shared_
doesn't seem to exist, and using UiStateLoading.shared
gives the following error:
Cannot convert value of type 'UiState<KotlinNothing>' to expected argument type 'UiState<RawProfile>'
Tadeas Kriz
12/19/2024, 4:07 PMNothing
does in Kotlin, where Nothing
conforms to any other type, so you can't really assign it this way