I've recently learned that the KMP team has updated the Kotlin Multiplatform project template to incorporate server code alongside the client code in the same project. While I'm familiar with code sharing between client platforms, I'm seeking guidance on what specific portions of the code can now be shared between the server and client platforms. I appreciate any insights or information on how to leverage this new capability introduced by the KMP team.
11/12/2023, 2:53 PM
If you mean by "client" code "frontend", then you can leverage KMP by sharing code from the server on the client to improve the client's offline behavior (eg early input validation, and some other business logic).
11/12/2023, 10:14 PM
It has to be said this is not a new capability of KMP, code sharing between client/server projects within an 'umbrella' Gradle project has been possible since the beginning. It's a very compelling setup if you own the whole stack! For a start, API models can be shared to guarantee synchronised (de)serialisation - especially useful when refactoring the API. Sharing some of the Domain can also support smart solutions like offline client functionality or intentionally moving some computation to the 'edge'. You can also design Gradle tasks to launch the server and client simultaneously for a tight development feedback loop. These are just a few examples; the possibilities of code share between client/server are many!
@Pitam Poudel you ask what can be shared... Any code can be, everything else is a recommendation 🙂
11/13/2023, 6:45 AM
Thanks for the information @darkmoon_uk@streetsofboston