https://kotlinlang.org logo
j

Jeff

08/25/2020, 7:46 AM
K 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 🙂
b

Big Chungus

08/25/2020, 8:10 AM
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
j

Jeff

08/25/2020, 8:19 AM
Thanks @Big Chungus but you neither answered question 1 nor 2 🙄
b

Big Chungus

08/25/2020, 8:28 AM
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