react-native-webview-comlink
react-native-webview-comlink copied to clipboard
Question: Is here a way to expose an object on the web side towards native?
Do I understand correctly that this lib only exposes a native api object inside the webview? Is there a way to also expose an api object from the webview side towards native?
Yes, it's currently designed to only exposes a native api object inside the webview. (native -> web). It support callbacks being passed in the native api, so if it's not a complex funcion that you want to expose to native at web side, it can be implemented by something like:
// native api object allows to register a api from web side
let webAPIMethod;
const apiObject = {
registerWebAPIMethod(method) {
webAPIMethod = method;
}
}
//
if (webAPIMethod) {
webAPIMethod('some', 'paramters');
}