The following is a method rewritten in Kotlin from Java:
fun publishMessageSource(
name: String,
address: String,
completionHandler: Handler<AsyncResult<Unit>>
) {
val record = MessageSource.createRecord(name, address)
publish(record, completionHandler)
}
However, when I call it as follows:
publishMessageSource("market-data", ADDRESS, { record: Handler<AsyncResult<Unit>> ->
if (!record.succeeded()) {
record.cause().printStackTrace()
}
println("Market-Data service published : ${record.succeeded()}")
})
I get the error Type Mismatch required Handler<AsyncResult<Unit>> found (Handler<AsyncResult<Unit>>) -> Unit
.
What am I doing wrong?