Closed michaelbrainvu closed 3 years ago
just try to use import struct SwiftUI.State
. it force import of SwiftUI State
, but you can't use State
from mpp in this case. Only with fullname: MultiPlatformLibrary.State
Maybe it's possible to rename State
to something like MokoState
or ViewState
, and Data
& Error
to something like Success
& Fail
(for now there are no such types in either SwiftUI or Combine frameworks). As more people are going to use SwiftUI it will remove some confusion.
@DmyMi agree. i think about ResourceState
name, or ViewState
yes.
sealed class ViewState<out T, out E> {
data class Success<out T, out E>(val data: T) : ViewState<T, E>()
data class Fail<out T, out E>(val error: E) : ViewState<T, E>()
class Loading<out T, out E> : ViewState<T, E>()
class Empty<out T, out E> : ViewState<T, E>()
}
seems good i think.
but required automatically refactoring tool for migration https://readyset.build/kotlin-deprecation-goodies-a35a397aa9b5 i think replaceWith
will help us. to implement it i think we should move current State
class into mvvm-deprecated
module, and in this module will be available old State
class with @Deprecated
mark and replaceWith
- to smooth update of current apps. in core mvvm
module we will not contain State
- but inly ViewState
start from 0.9.0 we have two modules:
mvvm-state-deprecated
with State
class that used nowmvvm-state
with ResourceState
class (renamed State
) - this will allow the class to be used with SwiftUIby default mvvm
umbrella artifact depends on mvvm-state-deprecated
now, to support smooth migration to new version.
When importing the MultiPlatformLibrary to a SwiftUI view I get an error "Unknown attribute @State". I think that the State class defined in moko-mvvm somehow causes this issue.