Thread
#multiplatform
    Jeff

    Jeff

    2 years ago
    :kotlin: Hello! Little question. How do I structure a multiplatform library that is basically an API wrapper for a third-party payment service. The library can be used in Multiplatform projects, Android and JS. 1. Is it even necessary for the library to include View Model and Data Repository? 2. Also, is it best to use callbacks or pure suspend functions? Really appreciate your advice 🙂
    Big Chungus

    Big Chungus

    2 years ago
    Use ktor client for rest calls and write all your code in common sourceSet. Then just declare android and js targets and vuolia (or however you spell it)! You have mpp lib
    You can write tests in common sourceSet too, meaning you shouldn't even need android and js sourcesets at all
    Jeff

    Jeff

    2 years ago
    Thanks @Big Chungus but you neither answered question 1 nor 2 🙄
    Big Chungus

    Big Chungus

    2 years ago
    My bad 😄 If i get your question right, you;re trying to write an http client for some REST API. In that case:1. No 2. Since you're targeting JS, try and avoid using coroutines best you can as it inflated total bundle size a lot and many ppl try to avoid them on js for that. i.e. Callbacks preferred
    However I should mention that if you choose to use ktor client, it brings coroutines with itself, so in that case you should favour suspend functions
    Chetan Sachdeva

    Chetan Sachdeva

    2 years ago