GithubHelp home page GithubHelp logo

Comments (4)

staltz avatar staltz commented on June 2, 2024 1

I think WebSockets would really help here, they give you that two-way communication channel that you want. Just use the package ws for node.js on the background process. On the React Native side, there is also WebSocket support, however it has been buggy lately but depending on the version of React Native you use, it may work.

from react-native-node.

soyuka avatar soyuka commented on June 2, 2024

WDYT about implementing a kind of IPC channel (like electron has) embedded in this library? It could use a TCP client in Java that interfaces sendMessage/onMessage methods available in react. On the backend something like:

const ipc = require('react-native-node').ipc
ipc.onMessage()
ipc.sendMessage()

This could wrap the origin nodejs process to avoid the boilerplate, and onMessage/sendMessage could be exposed globally.

If you're willing to accept such a feature please let me know and I'll definitely work on it!

from react-native-node.

staltz avatar staltz commented on June 2, 2024

Soyuka, note that react-native-node spawns a new process, not a new thread. So Java doesn't have any special privilege that JS wouldn't have, that's why I recommend using just JS directly with TCP or Websockets.

If you want to spawn a new JS thread, take a look at react-native-workers which has the API you suggested.

from react-native-node.

soyuka avatar soyuka commented on June 2, 2024

Mhh, yes I got that. Though I don't see why we couldn't have a TCP client in Java that connects to a node tcp server. This would give the ability to run sendMessage() from the react-native javascript and ease the communication process :).

I'll try a prototype!

from react-native-node.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.