Created
October 11, 2016 08:34
-
-
Save aesteve/dd6e8883ffe89061db320eca64bec528 to your computer and use it in GitHub Desktop.
Extension method in Kotlin to handle a method reference as a Handler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// It's weird it doesn't work ootb since Handler<T> is a functional java interface | |
// I must have missed something | |
fun <T> asHandler(handler: (T) -> Unit): Handler<T> = | |
Handler { event -> handler(event) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment