-
-
Save inderisonline/cdc1a67f9f535069c234f4943d84ff5d to your computer and use it in GitHub Desktop.
Demo code for callback interface with a high order function
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
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