问题标签 [react-native-jsi]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
569 浏览

c++ - What's the difference between bridging a module with C++ or with JSI in React Native?

In React Native it is possible to bring native functionality from Android and iOS in multiple ways. I always thought that all possible ways were limited by platform-related languages like Java/Kotlin and Objective-C/Swift. However, I noticed that it is still possible to bridge native functionality even from C++ (without using JSI). Specifically, I noticed that from react-native-builder-bob it is possible to easily start a package that bridges native modules using C++.

At this point I wonder, but what does JSI introduce that is new if it was already possible to integrate JS with C++? Why should it bring performance improvements over the current solution?

I apologise in advance for my lack of knowledge, but I really couldn't find the answer.

0 投票
1 回答
122 浏览

c++ - React Native JSI:如何将本机对象公开给 javascript 代码

我使用 RN 0.66.3 并希望在我的 iOS React Native 项目中直接同步调用从 javascript 到本机代码以共享数据,而不使用 React Native Bridge 来提高性能,因此我需要一个共享的全局对象并访问它来自javascript的属性和方法。

我知道 JSI(JavaScript 接口)可以做到这一点,但是没有文档和很少的教程,那么实现这个的简单步骤或示例代码是什么?

0 投票
1 回答
137 浏览

c++ - React Native JSI:如何从本机调用任何 javascript 函数?

我需要一个回调函数来侦听本机模块中的某些事件并将数据从本机传输到 javascript,我想直接在 React Native iOS 应用程序中从本机调用此 javascript 函数,而不将事件发送到NativeEventEmitter.

如何使用 JSI(JavaScript 接口)实现这一点?

0 投票
1 回答
92 浏览

c++ - React Native JSI:如何调用从原生到 javascript 公开承诺的函数

我需要在我的 React Native iOS 应用程序上使用来自 javascript 代码的自定义原生 fetch 函数,它必须是异步的,并且与标准函数一样工作。我想用 React Native JSI 来实现它,那么如何将异步函数暴露给 javascript?