Comments (4)
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.
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.
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.
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)
- Bundle again on app reload HOT 2
- es7 support HOT 1
- Run on Android 4.4.2 error
- nodejs-mobile HOT 2
- Weird behavior with livereload HOT 2
- package com.staltz.reactnativenode does not exist HOT 6
- NodeJS doesn't rebuild with new insert HOT 16
- Bunch'o questions HOT 2
- Approaches to running Node on Android HOT 3
- Considerations for choosing NodeBase instead of J2V8? HOT 6
- Unclear FAQ explanation on compiling native libraries HOT 2
- Running example code results in network error at RN fetch() HOT 21
- method does not override or implement a method from a supertype Error HOT 4
- iOS support HOT 1
- Expose server publicly? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-node.