Skip to content

Instantly share code, notes, and snippets.

@inderisonline
Last active October 27, 2022 12:39
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 inderisonline/cdc1a67f9f535069c234f4943d84ff5d to your computer and use it in GitHub Desktop.
Save inderisonline/cdc1a67f9f535069c234f4943d84ff5d to your computer and use it in GitHub Desktop.
Demo code for callback interface with a high order function
class HighOrderDemo @Inject constructor(
private val connectRemote: ConnectRemote,
) {
fun connect(connectionListener: (isConnected: Boolean) -> Unit) {
try {
connectRemote.connect{
connectionListener.invoke(it)
}
} catch (ex: Exception) {
connectionListener.invoke(false)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment