Skip to content

Instantly share code, notes, and snippets.

@amitkumar0000
Created January 31, 2022 18:12
Show Gist options
  • Save amitkumar0000/aa65133fdf5fbcf90136337501c2f6d8 to your computer and use it in GitHub Desktop.
Save amitkumar0000/aa65133fdf5fbcf90136337501c2f6d8 to your computer and use it in GitHub Desktop.
Producing party to consuming party communication
class SDKModule {
private fun requestReactHost(listener: ContainerListener) {
listener.onRequest(object: AppListener {
override fun onResponse(reactHost: String) {
Timber.d("Got the response: $reactHost")
}
})
}
fun initSetup(listener: SDKListener) {
listener.onRequest(object: AppListener {
override fun onResponse(response: String) {
print("Got the response")
}
})
}
}
interface SDKListener {
fun onRequest(response: AppListener)
}
interface AppListener {
fun onResponse(response: String)
}
class ConsumingApp: SDKListener {
fun init() {
SDKModule.initSetup(this)
}
override fun onRequest(req: AppListener) {
req.onResponse("response")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment