[K/JS] Export Channel interface itself as well as SendChannel and Rec… - #4716
[K/JS] Export Channel interface itself as well as SendChannel and Rec…#4716JSMonk wants to merge 2 commits into
Conversation
…eiveChannel ^KT-80733
|
The purpose of this addition is unclear to me.
You mention KT-80733 as the rationale, but that issue is dedicated to consuming a |
I believe people would want to export channels like this: @JsExport
class ViewModel {
val channel = Channel<Data>()
}And this will not work (the compiler will trigger a warning that Channel is not an exportable type). So people would need to write like this in common code: @JsExport
class ViewModel {
@JsExport.Ignore
val channel = Channel<Data>()
@JsName("channel")
val _channel: ReceiveChannel<Data> = channel
}To not make their life complicated, I think it is worth marking itself as a |
|
I wouldn't expect them to write code like this in the first place. Exposing a There's a new language feature to help with this: https://kotlinlang.org/docs/whatsnew23.html#explicit-backing-fields With it, the second snippet becomes class ViewModel {
val channel: ReceiveChannel<Data>
field = Channel<Data>()
} |
…eiveChannel
^KT-80733