Skip to content

Instantly share code, notes, and snippets.

@EmmanuelGuther
Created April 4, 2019 18:10
Show Gist options
  • Select an option

  • Save EmmanuelGuther/df05df6777489c6ee3188dcfccee43bc to your computer and use it in GitHub Desktop.

Select an option

Save EmmanuelGuther/df05df6777489c6ee3188dcfccee43bc to your computer and use it in GitHub Desktop.
Kotlin pass a function as parameter and execute
internal fun handleChatMessages(messages: List<MessageModel>?) {
hideProgress()
adapter.collection = messages.orEmpty()
animate { runLayoutAnimation() }
}
private fun animate(function: () -> Unit) {
when {
firstTimeCreated -> function.invoke()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment