【问题标题】:How to integrate thrift module with react native?如何将 Thrift 模块与 React Native 集成?
【发布时间】:2016-02-01 02:04:20
【问题描述】:

我正在使用 react-native(在 Linux 上)创建一些具有客户端-服务器协议的 android 应用程序。这个客户端-服务器协议是用 Thrift 制作的。

问题是 react-native 不能在 nodejs 环境中运行,Thrifit libs 大量使用原生 nodejs 模块,如 util、net、events、tls、child_process、http、https 等.我尝试使用 npm install 安装每个模块,但不适用于所有模块。

还有其他方法可以将所有本机 nodejs 模块安装到我的 react-native 应用程序吗?有人知道如何使用 thrift 和 react-native 吗?

【问题讨论】:

  • 我建议也可以在邮件列表中问这个问题..

标签: android node.js react-native thrift


【解决方案1】:

您所说的 Thrift 库是 NodeJS Thrift 库。

Thrift 拥有其他语言的库,如 Java、Python、C++ 等。

要让 Thrift 在 React Native Android 上运行,我建议你:

  1. Build the Android thrift libraries。
  2. 验证您的 Thrift 客户端是否在原生 Android 代码中运行。
  3. 创建一个 React Native Native Module(Java 桥接类)。
  4. 从 React Native Javascript 代码调用您的 Native Module。

希望这会有所帮助!

【讨论】:

  • 有没有办法让它在 ReactNative 端使用 javascript 工作? React 支持 Websockets 和其他一些东西。是否可以使用它们在 React Native 端实现所有工作,而无需在本地进行操作?
猜你喜欢
  • 1970-01-01
  • 2019-06-29
  • 1970-01-01
  • 2020-01-26
  • 1970-01-01
  • 2017-08-01
  • 2020-09-04
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多