fair_enough
08/14/2018, 8:22 AMMessageApi.prototype.onMessage_ep0k5p$ = function (listener) {
this.socketApi_0.addListener_lgim5c$(KWebSocket$Companion_getInstance().EVENT_MESSAGE, MessageApi$onMessage$lambda(listener));
};
This was not created:
Object.defineProperty(MessageApi.prototype, 'onMessage', {
get: function () {
return this.onMessage_ep0k5p;
}
});
This is the class:
class MessageApi(private val socketApi: ISocketApi, override val user: String = WebAppUser) : IMessageApi {
override fun onMessage(listener: MessageListener) {
socketApi.addListener(KWebSocket.EVENT_MESSAGE) {
it.data?.apply {
listener(this)
} ?: println("Message text was null: $it")
}
}
override fun send(text: String) {
socketApi.webSocket.send(SocketData(SocketDataType.Default, user, KWebSocket.EVENT_MESSAGE, text))
}
}
Roman Artemev [JB]
08/14/2018, 9:41 AMObject.defineProperty
is used for property accessors but in your case onMessage
is method, not a property.fair_enough
08/14/2018, 10:02 AMfair_enough
08/14/2018, 10:04 AMfair_enough
08/14/2018, 10:05 AMContentApi.prototype.on_taqqg7$ = function (listener) {
this.socketApi_0.addListener_lgim5c$(KWebSocket$Companion_getInstance().EVENT_CONTENT, ContentApi$on$lambda(listener));
};
ContentApi.prototype.test = function () {
println_0();
};
fair_enough
08/14/2018, 10:05 AMinterface ITest {
fun test()
}
class ContentApi(private val socketApi: ISocketApi) : IContentApi, ITest {
override fun on(listener: (IContentItem) -> Unit) {
socketApi.addListener(KWebSocket.EVENT_CONTENT) {
it.data?.apply {
listener(JSON.parse<ContentItem>(this))
} ?: println("Content item was null: $it")
}
}
override fun test() {
println()
}
}
fair_enough
08/14/2018, 10:08 AMContentApi.$metadata$ = {
kind: Kind_CLASS,
simpleName: 'ContentApi',
interfaces: [ITest, IContentApi]
};
function IContentApi() {
}
IContentApi.$metadata$ = {
kind: Kind_INTERFACE,
simpleName: 'IContentApi',
interfaces: []
};
fair_enough
08/14/2018, 10:12 AMfair_enough
08/14/2018, 10:12 AMfair_enough
08/14/2018, 10:13 AMRoman Artemev [JB]
08/14/2018, 10:29 AMonMessage
with JsName("onMessage")
fair_enough
08/14/2018, 11:28 AM