Git Product home page Git Product logo

Comments (4)

Alex009 avatar Alex009 commented on July 30, 2024

your generated swift code outdated. in kotlin source you have some new cases in sealed, but in swift code this cases not used yet

from moko-kswift.

aleksey-ho avatar aleksey-ho commented on July 30, 2024

@Alex009, Hi, Thank you for quick reply! Here's my sealed class UIState and UserPremium used in MutableStateFlow<UIState>(UIState.Empty)

sealed class UIState<out T> {
    object Loading : UIState<Nothing>()
    object Empty : UIState<Nothing>()
    data class Data<T>(val value: T) : UIState<T>()
    data class Error(val throwable: Throwable) : UIState<Nothing>()
}

data class UserPremium(val isActive: Boolean, val state: SubscriptionState)

enum class SubscriptionState {
    AVAILABLE, BILLING_ISSUE, CANCELLED, ERROR
}

and generated UIStateKs:

public enum UIStateKs<T : AnyObject> {

  case data(UIStateData<T>)
  case empty
  case error(UIStateError)
  case loading

  public var sealed: UIState<T> {
    switch self {
    case .data(let obj):
      return obj as MultiPlatformLibrary.UIState<T>
    case .empty:
      return MultiPlatformLibrary.UIStateEmpty() as! MultiPlatformLibrary.UIState<T>
    case .error(let obj):
      return obj as! MultiPlatformLibrary.UIState<T>
    case .loading:
      return MultiPlatformLibrary.UIStateLoading() as! MultiPlatformLibrary.UIState<T>
    }
  }

  public init(_ obj: UIState<T>) {
    if let obj = obj as? MultiPlatformLibrary.UIStateData<T> {
      self = .data(obj)
    } else if obj is MultiPlatformLibrary.UIStateEmpty {
      self = .empty
    } else if let obj = obj as? MultiPlatformLibrary.UIStateError {
      self = .error(obj)
    } else if obj is MultiPlatformLibrary.UIStateLoading {
      self = .loading
    } else {
      fatalError("UIStateKs not synchronized with UIState class")
    }
  }

}

is there anything I need to change? I's not clear for me why is it working on simulator but not in festflight build

from moko-kswift.

Alex009 avatar Alex009 commented on July 30, 2024

strange. what value you have in UIState<T> when fatalError throws?

from moko-kswift.

aleksey-ho avatar aleksey-ho commented on July 30, 2024

Unfortunately, I can't get the value in debug environment. It crashes only in testflight build
Снимок экрана 2024-07-03 в 11 33 47

from moko-kswift.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.