I'm building a React Native module with Kotlin. I have an external Java SDK that can discover peripherals on multiple protocols / networks / servers.
There is a Discovery class like this :
class Discovery(params: Params) {
fun start() {
// ...
}
fun stop() {
// ...
}
}
I want to pass a startDiscovery() and stopDiscovery() functions to React Bridge.
The client can search for many devices on multiple protocols / servers / ... at the same time. So it would require the instantiation of many Discovery class at the same time and stop some of them if necessary. Some sort of a Pool of discoveries.
So I would like to pass a reference to the instantiated object to Javascript so it can give back to me each time it want to call another method. But React Bridges doesn't allow to pass Java objets to JavaScript. Is there any good pattern to do so ?
Just try to make async actions in java so the thread not get stuck and you don't lose performance(return promises if you have async actions).
In your javascript code