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.

Revisions

  1. amitkumar0000 created this gist Jan 31, 2022.
    35 changes: 35 additions & 0 deletions SDK to APP communication
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    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")
    }