Skip to content

Instantly share code, notes, and snippets.

@aesteve
Created October 11, 2016 08:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aesteve/dd6e8883ffe89061db320eca64bec528 to your computer and use it in GitHub Desktop.
Save aesteve/dd6e8883ffe89061db320eca64bec528 to your computer and use it in GitHub Desktop.
Extension method in Kotlin to handle a method reference as a Handler
// 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