michaelbull / kotlin-result

A multiplatform Result monad for modelling success or failure operations.
ISC License
1.07k stars 64 forks source link

Kotlin multi-platform support #12

Closed SrgGrch closed 4 years ago

SrgGrch commented 4 years ago

This question was already raised (here #5), but still, I am not able to use this library in the Multiplatform project. I think this is due to differences between the android library's build.gradle and the multiplatform one. In the MP library you need to specify kotlin("multiplatform") plugin and divide code into source sets (for that specific library you will need only common source set). You can read more about [https://kotlinlang.org/docs/tutorials/mpp/multiplatform-library.html](Multiplatform Kotlin library) at kotlintlang.org

I've tested this library with MP "structure" and it seems to work, so if you are interested in supporting MP I can create PR for this and you will check out code.

michaelbull commented 4 years ago

Hi, thanks for raising this. Last time I tried I had trouble publishing to bintray with the MPP structure, however we've since moved to Maven Central - therefore it isn't a blocker anymore as I've already achieved it in my kotlin-inline-logger library.

I'll try and copy what I did in my other library and get it working with the MPP structure soon. Thanks.

joreilly commented 4 years ago

Starting from Kotlin 1.4 it should be possible to effectively call suspend functions from iOS etc code....do you know if this could be used as return type for functions like this?

michaelbull commented 4 years ago

Hi, I tried giving this a go but couldn't get it to play well with the benchmarking framework. Perhaps you can give it a go?

I also tend to wonder what is actually stopping you from using it in a mpp in its current state. It doesn't depend on the jvm specific version of the kotlin stdlib, so even though you are importing it as a jar from maven central it should still be compiled against the platform agnostic kotlin-stdlib.

Munzey commented 4 years ago

I can try get this working ✋

Munzey commented 4 years ago

@michaelbull i have the benchmarking framework now working with mpp. It seems to be very picky about how the source set can be registered. I will put up a pr later today with proposed mpp structure (other than getting benchmarking working its basically a copy paste of kotlin-inline-logger gradle script).

avently commented 4 years ago

@michaelbull for now I'm unable to use the lib inside commonMain part of my application. Do you plan to support it too? Or maybe just to merge #18 if it works in this case?

michaelbull commented 4 years ago

@Munzey has kindly added this functionality which is now released as part of 1.1.7

Skeptick commented 4 years ago

But ... Why only jvm? Are there any restrictions that prevent all other platforms from being included? I use the library with iOS, but I have to copy the source files to the project.

michaelbull commented 4 years ago

@Skeptick you can see the discussion on that subject here. If you would like to tackle adding other implementations (there's only one platform-specific class) then I am open to accepting a PR 👍

Munzey commented 4 years ago

@Skeptick like @michaelbull mentioned, the main thing required is to add the platform specific impl - which i believe should be as straightforward as adding a dir for the desired platform, adding an

internal actual object BindException : Exception()

and then adding the corresponding mpp config to the gradle build file

Munzey commented 4 years ago

ive got some time today, will look at putting a pr up for this

Munzey commented 4 years ago

opened pr to add ios targets see #23