Generated code
+
-// In case of a SharedFlow the plugin would generate this native replay cache property
-val timeNativeReplayCache
- get() = time.replayCache
+The plugin will generate this native property for you:
+```kotlin
+@ObjCName(name = "time")
+val Clock.timeNative
+ get() = time.asNativeFlow()
```
-The plugin also generates `Native` versions for all your suspend functions:
+For the `StateFlow` defined above the plugin will also generate this value property:
```kotlin
-class RandomLettersGenerator {
- // Somewhere in your Kotlin code you define a suspend function
- suspend fun getRandomLetters(): String {
- // Code to generate some random letters
- }
-
- // The plugin will generate this native function for you
- fun getRandomLettersNative() =
- nativeSuspend { getRandomLetters() }
-}
+val Clock.timeValue
+ get() = time.value
```
-#### Global properties and functions
-
-The plugin is currently unable to generate native versions for global properties and functions.
-In such cases you have to manually create the native versions in your Kotlin native code.
-
-#### Custom suffix
-
-If you don't like the naming of these generated properties/functions, you can easily change the suffix.
-For example add the following to your `build.gradle.kts` to use the suffix `Apple`:
+In case of a `SharedFlow` the plugin would generate a replay cache property:
```kotlin
-nativeCoroutines {
- suffix = "Apple"
-}
+val Clock.timeReplayCache
+ get() = time.replayCache
```
+
+
-#### Custom CoroutineScope
+#### StateFlows
-For more control you can provide a custom `CoroutineScope` with the `NativeCoroutineScope` annotation:
+Using `StateFlow` properties to track state (like in a view model)?
+Use the `@NativeCoroutinesState` annotation instead:
```kotlin
class Clock {
- @NativeCoroutineScope
- internal val coroutineScope = CoroutineScope(job + Dispatchers.Default)
+ // Somewhere in your Kotlin code you define a StateFlow property
+ // and annotate it with @NativeCoroutinesState
+ @NativeCoroutinesState
+ val time: StateFlow