DeepMedia logo
Open Source
Search...

Other versions of this page

Improve this page on GitHub

Search

Features

As described in concepts, to use Knee you must annotate your Kotlin/Native declarations and they'll be made available in Kotlin/JVM. As a general rule:

  • Use @Knee on callables functions or properties
  • Use @KneeClass, @KneeInterface, @KneeEnum on types (or typealiases)

This way, the following Kotlin/Native code:

kotlin
@KneeClass class User(val id: String) @KneeClass class LoggedOutException : RuntimeException() @KneeClass class Post @Knee constructor(@Knee val title: String, @Knee val author: User) @KneeInterface typealias PostSavedCallback = (Post) -> Unit @KneeClass class Database() { private val scope: CoroutineScope = ... private val disk: Disk = ... @Knee suspend fun getCurrentUser(): User { val user = disk.readCurrentUserSuspending() return user ?: throw LoggedOutException() } @Knee fun savePostAsync(post: Post, callback: PostSavedCallback) { scope.launch { disk.writePostSuspending(post) callback(post) } } } @Knee val AppDatabase: Database = ...

...can be seamlessly called from the JVM side - no boilerplate, no glue code, everything is handled for you:

kotlin
suspend fun createPost(title: String): Post { val user = try { AppDatabase.getCurrentUser() } catch (e: LoggedOutException) { TODO("Handle this") } return Post(title, author = user) } fun savePost(post: Post) { AppDatabase.savePostAsync(post) { savedPost -> check(savedPost == post) } }

We list most features supported by the Knee compiler below:

More

Subscribe to the DeepMedia Newsletter

The latest news about DeepMedia products, open source projects and software development at our company.

By clicking “Subscribe”, you agree that DeepMedia may use your email address to send you newsletters, including commercial communications, and to process your personal data for this purpose. You agree that DeepMedia may process said data using third-party services for this purpose in accordance with the DeepMedia Privacy Policy. You can revoke this consent at any time using the unsubscribe link included in each email or by writing at contact@deepmedia.io.