You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm migrating to KMP-NativeCoroutines and things are working really well so far.
I'm a bit confused on how to use @NativeCoroutinesState with StateFlow.
I have a Kotlin class with the following members:
private val _foo = MutableStateFlow<Double>(1.0)
@NativeCoroutinesState
val foo = _foo.asStateFlow()
in my Swift view model I have the following:
let myFoo: Double = node.foo // this works
createPublisher(for: node.fooFlow)
.sink(
receiveCompletion: { completion in },
receiveValue: { newValue in
let myFoo2: Double = newValue // this fails with error: Cannot convert value of type 'KotlinDouble' to specified type 'Double'
}
)
.store(in: &cancellables)
I was expecting node.fooFlow to give me a type Double, not KotlinDouble.
Also, I'm not sure how to use @NativeCoroutinesRefinedState. If I try using @NativeCoroutinesRefinedState in the above code the member is simply removed.
The text was updated successfully, but these errors were encountered:
I was expecting node.fooFlow to give me a type Double, not KotlinDouble.
Yeah there are some edge cases in the Kotlin-ObjC interop when used with callbacks (which are being generated by KMP-NativeCoroutines).
You could indeed make this a little nicer with @NativeCoroutinesRefinedState.
Also, I'm not sure how to use @NativeCoroutinesRefinedState. If I try using @NativeCoroutinesRefinedState in the above code the member is simply removed.
Correct, the refined annotations effectively hide the declarations from autocomplete.
The declarations still exist, but are prefixed with __. Something like the following should work:
Hi, I'm migrating to KMP-NativeCoroutines and things are working really well so far.
I'm a bit confused on how to use @NativeCoroutinesState with StateFlow.
I have a Kotlin class with the following members:
in my Swift view model I have the following:
I was expecting node.fooFlow to give me a type Double, not KotlinDouble.
Also, I'm not sure how to use @NativeCoroutinesRefinedState. If I try using @NativeCoroutinesRefinedState in the above code the member is simply removed.
The text was updated successfully, but these errors were encountered: